Using C Language
Print all character from ASCII Table within the range of 32 – 126 (inclusive of both end points) using a for loop, do while loop and a while loop. Compute a sum for each loop of the looping constructs and compare the sums at the end of the program. If all three sums equal print “OK” and if they are different print “DIFFERENT”
The Code Is:
#include<stdio.h>
int main()
{
int
i,j,k,for_loop_sum=0,while_loop_sum=0,do_while_loop_sum=0;
printf("ASCII table using for loop. ");
for(i=32;i<=126;i++)
{
printf("%d %c | ",i,i);
for_loop_sum+=1;
}
printf(" ");
printf("ASCII table using while loop. ");
j=32;
while(j<=126)
{
printf("%d %c |",j,j);
while_loop_sum+=1;
j++;
}
printf(" ");
printf("ASCII table using do while loop. ");
k=32;
do
{
printf("%d %c | ",k,k);
do_while_loop_sum+=1;
k++;
}while(k<=126);
printf(" ");
if(for_loop_sum==while_loop_sum &&
while_loop_sum==do_while_loop_sum &&
do_while_loop_sum==for_loop_sum)
{
printf("OK");
}
else
{
printf("DIFFERENT");
}
return 0;
}
The output is:



Using C Language Print all character from ASCII Table within the range of 32 – 126...