C programming

April 1, 2009 at 18:49:58
Specs: Windows XP, 768mb
Write a C program to convert an upper case
word to lower case and vice-versa.

See More: C programming

Report •


#1
April 2, 2009 at 02:48:38
One way could be...
#include <ctype.h>
...

char str[] = "lower case string";
int i;

puts(str);
for(i=0; (str[i] = toupper(str[i])) != '\0'; i++) {}
puts(str);
for(i=0; (str[i] = tolower(str[i])) != '\0'; i++) {}


Report •

#2
April 2, 2009 at 19:51:51
Hi this is rs,

#include<stdio.h>
#include<conio.h>
int main(void)
{
char ch;
int i,j;
clrscr();
scanf(%c",&ch);
i=ch;//converts to ASCII value(implicit datatype conversion)
i=i+32;//since A & a have ASCII value 65 & 97 resp.,
ch=i;//again implicit datatype conversion
printf("\nThe upper case is : %c",ch);
getch();
}

The above program will serve your purpose


Report •

#3
April 2, 2009 at 20:42:34

Report •

Related Solutions

#4
April 9, 2009 at 01:12:15
This might help you.......please check this out..

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

int stringtoupper(char *str)
{
while(*str)
{
*str = toupper(*str);
*str++;
}
return 0;
}


int main(int argc, char *argv[])
{
char s[] = "hElLo";
stringtoupper(s);
printf("%s\n",s);
system("PAUSE");
return 0;
}

Thanks & Regards
SP.


Report •


Ask Question