Pages

Monday, October 10, 2011

4.Programming in C++ with output

WAP TO ENTER A STRING AND CHANGE ITS CASE USING FUNCTIONS



#include<conio.h>
#include<iostream.h>
#include<string.h>
#include<stdio.h>
#include<ctype.h>
void convert(char[40]);
void main()
{
clrscr();
char ch[40];
cout<<"Enter a string::";
gets(ch);
convert(ch);
getch();
}
void convert(char x[40])
{
int i;
for(i=0;i<strlen(x);i++)
{
if(islower(x[i]))
x[i]=toupper(x[i]);
else
x[i]=tolower(x[i]);
}
puts(x);
}

No comments: