Friday, August 04, 2006

Formatted output ABCEDFG using Nested For Loops.

Write a program to produce the following output:

ASCII value of A through F = 65 to 71
ASCII value of Space = 32


int iteration, space, last=70,new_value=70, put_space=1;

char alphabet;


//This for loop decides the number of iterations that are to be carried out.
for (iteration=1; iteration<=6; iteration++)


//This for loop is for incrementing the alphabets

for (alphabet=65; alphabet<=last; alphabet++)

printf("%c", alphabet);


//This for loop is for generating the appropriate spaces.
//space variable decides the number of times we require the spaces,
//and put_space is the actual variable that determines the number of spaces.
for (space=1; space<=put_space; space++)

printf("%c", 32);


//This for loop is for decrementing the alphabets.
for (alphabet=new_value; alphabet>=65; alphabet--)

printf("%c", alphabet);


The file can be found at:
Download File


surya said...

become a follower for free C,C++ And vb code of my blog: to learn C,C++,VB programming.

Ashu said...

Owe some brother, this helps me a lot. Thank you very much

Shalini said...

easy understandable logics

Kartikey said...

I saw many websites using a very complicatedlogic but this one is easy to know...

Ashish Chaudhary said...

your logic is good...but your program is complicated with lot of errors

Anonymous said...

Can anyone please give me the converted code of this into C++ ??