Question

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

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”

0 0
Add a comment Improve this question Transcribed image text
Answer #1

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:

Add a comment
Know the answer?
Add Answer to:
Using C Language Print all character from ASCII Table within the range of 32 – 126...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT