
Loop Control Statements II-127
16. Program to display string.
void main()
{
int i=0;
char a[5]={'A','s','h','o','k'};
clrscr();
printf("\nTransmitted information is:-");
while(i<=4)
{
printf("%c",a[i]);
i++;
}
printf("\n Received information is:-");
i=0;
while (i<=4)
{
printf("%c",a[i]+3);
i++;
}
getche();
}
OUTPUT:
Transmitted information is:- A s h o k
Received information is:- D v k r n
17. Program to display factorial of 6.
void main()
{
int a=6,b=1,fact=1;
clrscr();
do
{
fact=fact*b;
b=b+1;
}
while(b<=a);
printf("%d",fact);
getche();
}
OUTPUT:
720
M06_ITL-ESL4791_02_SE_C06.indd 127 12/22/2012 5:02:23 PM