Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- task-1;
- (a)
- #include <stdio.h>
- #include <string.h>
- int main(){
- char str [101];
- int ch,i=0;
- while((ch=getchar())!='\n'){
- str[i++]=ch;
- }
- str[i]='\0';
- for (int j=i-1;j>=0;j--){
- printf("%c",str[j]);
- }
- }
- (b)
- #include <stdio.h>
- #include <string.h>
- int main(){
- char str [101];
- int ch,i=0;
- while((ch=getchar())!='\n'){
- str[i++]=ch;
- }
- str[i]='\0';
- int j=i-1;
- char *pointer=&str[0], *p;
- for (p=pointer+j;p>=pointer;p--){
- printf("%c",*(p));
- }
- }
- (c)
- #include <stdio.h>
- #include <string.h>
- int main(){
- char str [101];
- int ch,i=0;
- while((ch=getchar())!='\n'){
- str[i++]=ch;
- }
- str[i]='\0';
- int j=i-1;
- char *p;
- for (p=str+j;p>=str;p--){
- printf("%c",*(p));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement