The need:
This program draws a triangle of ABCD on the output screen. This program was written to show that we can increment the characters like numbers.
This program draws a triangle of ABCD on the output screen. This program was written to show that we can increment the characters like numbers.
--------------------------------------------
#include<stdio.h>
main()
{
char z;
int j,i,k;
printf("Enter the number of rows..(1 to 26)\t");
scanf("%d",&k);
if(k<1||k>26)
{
printf("\nThe number entered was not in range of 1 to 26\n");
printf("exiting...\n");
exit(0);
}
printf("\n\n");
for (i=1;i<=k;i++)
{
z = 'A';
for (j=0;j<i;j++)
{
printf ("%c ",z);
z++;
}
printf("\n\n");
}
}--------------------------------------------
The approach:
This program is very much similar to that star triangle program(program34 of this blog) with only addition of a character variable z which is getting printed each time in place of star(*). z is also incremented each time thus printing different values in each print in row. When a new row starts z is again initialized with character literal 'A' and the loop repeats.
The approach:
This program is very much similar to that star triangle program(program34 of this blog) with only addition of a character variable z which is getting printed each time in place of star(*). z is also incremented each time thus printing different values in each print in row. When a new row starts z is again initialized with character literal 'A' and the loop repeats.
below is the answer of your question -
ReplyDeletehttp://programsimply.blogspot.com/2011/08/abcd-pattern2.html
I hope you are not getting your homework done by me. :)