sahajjain01

Toggle case of letters of a string.

Sep 21st, 2013
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.34 KB | None | 0 0
  1. //Program to toggle case of letters of a string.
  2. #include<iostream.h>
  3. #include<conio.h>
  4. #include<stdio.h>
  5. #include<ctype.h>
  6. void main()
  7. {
  8.     clrscr();
  9.     char a[80];
  10.     cout<<"Enter a string: ";
  11.     gets(a);
  12.     for(int i=0;a[i]!='\0';i++)
  13.     {
  14.         if(isupper(a[i]))
  15.         a[i]=tolower(a[i]);
  16.         else
  17.         a[i]=toupper(a[i]);
  18.     }
  19.     puts(a);
  20.     getch();
  21. }
Advertisement
Add Comment
Please, Sign In to add comment