Advertisement
sivan_iut

Untitled

Jul 14th, 2020
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.87 KB | None | 0 0
  1. task-1;
  2. (a)
  3. #include <stdio.h>
  4. #include <string.h>
  5.  
  6. int main(){
  7.     char str [101];
  8.     int ch,i=0;
  9.    
  10.     while((ch=getchar())!='\n'){
  11.         str[i++]=ch;
  12.     }
  13.     str[i]='\0';
  14.    
  15.     for (int j=i-1;j>=0;j--){
  16.         printf("%c",str[j]);
  17.     }
  18. }
  19.  
  20. (b)
  21. #include <stdio.h>
  22. #include <string.h>
  23.  
  24. int main(){
  25.     char str [101];
  26.     int ch,i=0;
  27.    
  28.     while((ch=getchar())!='\n'){
  29.         str[i++]=ch;
  30.     }
  31.     str[i]='\0';
  32.     int j=i-1;
  33.    
  34.     char *pointer=&str[0], *p;
  35.    
  36.     for (p=pointer+j;p>=pointer;p--){
  37.         printf("%c",*(p));
  38.     }
  39. }
  40.  
  41. (c)
  42. #include <stdio.h>
  43. #include <string.h>
  44.  
  45. int main(){
  46.     char str [101];
  47.     int ch,i=0;
  48.    
  49.     while((ch=getchar())!='\n'){
  50.         str[i++]=ch;
  51.     }
  52.     str[i]='\0';
  53.     int j=i-1;
  54.    
  55.     char *p;
  56.    
  57.     for (p=str+j;p>=str;p--){
  58.         printf("%c",*(p));
  59.     }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement