Virajsinh

A_PRM_13

Oct 7th, 2017
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.28 KB | None | 0 0
  1. /* Write a program using pointer variables to read a character
  2. until * is entered. If the character is in upper case,
  3. print it in lower case and vice versa. Also count the no.
  4. of upper and lower case characters entered. */
  5.  
  6. #include<conio.h>
  7. #include<stdio.h>
  8.  
  9. void main()
  10. {
  11.     char ch, *c;
  12.     int u=0, l=0;
  13.     clrscr();
  14.     c=&ch;
  15.  
  16.     printf("\n-----------------------------------------------------------------------------");
  17.     printf("\n Enter Character Convert Opposite Case And Count Character Upper And Lower");
  18.     printf("\n-----------------------------------------------------------------------------");
  19.     printf("\n Note Exit Program Enter '*' Sybol");
  20.     printf("\n-----------------------------------------------------------------------------");
  21.  
  22.     printf("\n Enter Character : ");
  23.     scanf("%c",&ch);
  24.  
  25.     while(*c !='*')
  26.     {
  27.             if(*c >= 'A' && *c <= 'Z')
  28.             {
  29.                     *c=*c+32;
  30.                     u++;
  31.             }
  32.             else if(*c >= 'a' && *c <= 'z')
  33.             {
  34.                     *c=*c-32;
  35.                     l++;
  36.             }
  37.             printf(" Character : %c", *c);
  38.             printf("\n\n Enter Character : ");
  39.             fflush(stdin);
  40.             scanf("%c",c);
  41.     }
  42.     printf("\n-------------------------------------");
  43.     printf("\n No. Of Upper Character is %d",u);
  44.     printf("\n No. Of Lower Character is %d",l);
  45.     printf("\n-------------------------------------");
  46.     getch();
  47. }
Add Comment
Please, Sign In to add comment