Loop Control Statements 183
printf ("
Enter a character
c=getche();
if(c~toupper(c))
printf (" lt's Lower Case :%c",c+32);
else
printf (" lt's Upper Case :%c",c-32);
OUTPUT;
* Enter 'E' to exit
* Enter only characters
Enter a character; s It's Upper Case :S
Enter a character: A It's Lower Case : a
Enter a character: E It's Lower Case : e
Explanation In the above mentioned program character variable ' c # is declared. The value is read
through getch e () function and stored in variable 'cIf the entered character which is stored in 'c',
is in upper case, then it's small case is printed or vice versa. The difference between all capital and
their small case characters in ASCII value is always 32. For example % A' has ASCII value 65 and for
' a ' has 97 and the difference between them is 32. When the entered character is in uppercase 32 is to
be added in its ASCII value to get the character in lower case. Otherwise for conversion of lower to
upper case 32 is subtracted from its ASCII value.
6.70 Write a program to use three while nested loops. Print numbers after each iteration &
messages after termination of each loop.
#include<stdio. h>
#include <conio.h>
void main ()
{
int i=l,j=l,k=l;
clrscr();
while (i<4)
I
while (j<3)
I
while (k<2)
{
printf ("
i=%dj=%d k~%d",i,j,k);
/c++,*
1
printf C'n Inner Loop (k) Completed/');
k-1;
/++;
I
printf ("n Middle Loop (j) Completed.");
H :