Sie sind auf Seite 1von 2

/*

anand g. upadhyay
roll no. 52
icaa
*/
#include <conio.h>
#include <stdio.h>
int size;
void read_char_array(char ch[])
{
int i;
printf("\nEnter your String of %d length ",size-1);
for(i=0;i<size;i++)
scanf("%c",&ch[i]);
}
void display_char_array(char ch[],FILE *fp)
{
printf(" : %s",ch);
fprintf(fp," %s",ch);
}
void lowtoup(char ch[])
{
int i;
for(i=0;i<size;i++)
{
if(ch[i]>=97 && ch[i]<=122)
{
ch[i]=ch[i]-32;
}
}
}
void uptolow(char ch[])
{
int i;
for(i=0;i<size;i++)
{
if(ch[i]>=65 && ch[i]<=91)
{
ch[i]=ch[i]+32;
}
}
}
int main()
{
FILE *fp;
fp=fopen("c:\\tc\\bin\\utol.txt","w");
if(fp==NULL)
{
printf("Sorry ! File Can not be Opened ");
exit(1);
}
char s[20];
int n;
clrscr();
printf("\n Enter length of String :");
scanf("%d",&n);
size=n+1;
read_char_array(s);
printf(" \nOriginal String ");
display_char_array(s);
printf("\nConverted to Uppercase");
lowtoup(s);
display_char_array(s);
printf("\nConverted to Lowercase");
uptolow(s);
display_char_array(s);
getch();
return 0;
}

Das könnte Ihnen auch gefallen