Showing posts with label Toggle case of letters. Show all posts
Showing posts with label Toggle case of letters. Show all posts

C++ Program to toggle case of letters of a String

How to write C++ Program to toggle case of letters of a string in C++ programming language ?

C++ Program to toggle case of letters of a String


Solution:
//Program to toggle case of letters of a string.
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<ctype.h>
void main()
{
clrscr();
char a[80];
cout<<"Enter a string: ";
gets(a);
for(int i=0;a[i]!='\0';i++)
{
if(isupper(a[i]))
a[i]=tolower(a[i]);
else
a[i]=toupper(a[i]);
}
puts(a);
getch();
}

This C++ Program to toggle case of letters of a String.