===========================================================================
CODING
#include<all.h>
void main()
{
clrscr();
int i,n;
char str[80],c,d;
gotoxy(1,2);
cout<<"Enter Paragraph:- ";
gotoxy(1,3);
gets(str);
cout<<"\n\nWhat do you waant to conert this para. into?\n";
cout<<" Small->1 Capital->2\n";
cout<<" Capitalize->3 Advance_Capitalize->4\n";
cout<<" ¯Choice: ";
cin>>n;
cout<<"\n\n ";
switch(n)
{
case 1:
for(i=0;str[i]!='\0';i++)
{
if(str[i]>=65 && str[i]<=90)
{
c=str[i]+32;
}
else
{
c=str[i];
}
cout<<c;
}
break;
case 2:
for(i=0;str[i]!='\0';i++)
{
if(str[i]>=97 && str[i]<=122)
c=str[i]-32;
else
c=str[i];
cout<<c;
}
break;
case 3:
for(i=0;str[i]!='\0';i++)
{
if(str[i-1]==' ' || i==0 )
{
if(str[i]>=97 && str[i]<=122)
c=str[i]-32;
else
c=str[i];
}
else if(str[i-1]!=' ')
{
if(str[i]>=65 && str[i]<=90)
c=str[i]+32;
else
c=str[i];
}
cout<<c;
}
break;
case 4:
for(i=0;str[i]!='\0';i++)
{
if(str[i-1]==' ' || i==0 || str[i+1]=='\0')
{
if(str[i-2]>=97 && str[i-2]<=122)
d=str[i-2]-32;
else
d=str[i-2];
if(str[i]>=97 && str[i]<=122)
{
c=str[i]-32;
}
else
c=str[i];
if(str[i-1]==' ')
{
cout<<"\b\b"<<d<<" ";
cout<<c;
}
if((i==0 && str[0]!=' ')|| str[i+1]=='\0')
cout<<c;
}
else
{
if(str[i]>=65 && str[i]<=90)
c=str[i]+32;
else
c=str[i];
cout<<c;
}
}
break;
default:cout<<"WRONG INPUT";
exit(0);
}
getch();
}
CODING
#include<all.h>
void main()
{
clrscr();
int i,n;
char str[80],c,d;
gotoxy(1,2);
cout<<"Enter Paragraph:- ";
gotoxy(1,3);
gets(str);
cout<<"\n\nWhat do you waant to conert this para. into?\n";
cout<<" Small->1 Capital->2\n";
cout<<" Capitalize->3 Advance_Capitalize->4\n";
cout<<" ¯Choice: ";
cin>>n;
cout<<"\n\n ";
switch(n)
{
case 1:
for(i=0;str[i]!='\0';i++)
{
if(str[i]>=65 && str[i]<=90)
{
c=str[i]+32;
}
else
{
c=str[i];
}
cout<<c;
}
break;
case 2:
for(i=0;str[i]!='\0';i++)
{
if(str[i]>=97 && str[i]<=122)
c=str[i]-32;
else
c=str[i];
cout<<c;
}
break;
case 3:
for(i=0;str[i]!='\0';i++)
{
if(str[i-1]==' ' || i==0 )
{
if(str[i]>=97 && str[i]<=122)
c=str[i]-32;
else
c=str[i];
}
else if(str[i-1]!=' ')
{
if(str[i]>=65 && str[i]<=90)
c=str[i]+32;
else
c=str[i];
}
cout<<c;
}
break;
case 4:
for(i=0;str[i]!='\0';i++)
{
if(str[i-1]==' ' || i==0 || str[i+1]=='\0')
{
if(str[i-2]>=97 && str[i-2]<=122)
d=str[i-2]-32;
else
d=str[i-2];
if(str[i]>=97 && str[i]<=122)
{
c=str[i]-32;
}
else
c=str[i];
if(str[i-1]==' ')
{
cout<<"\b\b"<<d<<" ";
cout<<c;
}
if((i==0 && str[0]!=' ')|| str[i+1]=='\0')
cout<<c;
}
else
{
if(str[i]>=65 && str[i]<=90)
c=str[i]+32;
else
c=str[i];
cout<<c;
}
}
break;
default:cout<<"WRONG INPUT";
exit(0);
}
getch();
}
===========================================================================
No comments:
Post a Comment