C > Beginners Lab Assignments
Prg. to convert upper case to lower case or lower case to upper case
Prg. to convert upper case to lower case or lower case to upper case depending on the name it is invoked with as found in argument. #include
#include
void lower_to_upper(); void upper_to_lower(); void main() { int n; clrscr(); printf(" Please enter your choice."); printf(" (1) for upper to lower conversion."); printf(" (2) for lower to upper conversion."); printf(" CHOICE:- "); scanf("%d",&n); switch (n) { case 1: { printf("Please enter a string in upper case."); printf(" String will be terminated if you press Ctrl-Z."); printf(" STRING:- "); upper_to_lower(); break; } case 2: { printf("Please enter a string in lower case."); printf(" String will be terminated if you press Ctrl-Z."); printf(" STRING:- "); lower_to_upper(); break; } default: printf("ERROR"); } printf(" HAVE A NICE DAY! BYE."); getch(); } void upper_to_lower() { int i,j; char c4[80],c3; for (i=0;(c3=getchar())!=EOF;i++) c4[i]=(c3>='A' && c3<='Z')?('a' + c3 -'A'):c3; printf(" The lower case equivalent is "); for (j=0;j
='a' && c1<='z')?('A' + c1 -'a'):c1; printf(" The upper case equivalent is "); for (j=0;j
C Codes
Beginners
C on Unix
Code Snippets
Data Structures
File Operations
Games Graphics
Gnu-Linux
Hardware
Mathematics
Miscellaneous
Small Programs
Sorting