Tuesday, September 2, 2014

print the following pattern on the screen (console)


Problem

Write a program to generate the following pattern on screen.
A
A B
A B C
A B C D
A B C D E
A B C D E F

Solution - Code

#include<stdio.h>
int main()
{
 int i,j;
 for(i=1;i<=6;i++)
 {
  char ch='A';
  for(j=1;j<=i;j++)
  {
   printf("%c",ch);
   ch++;
  }
  printf("\n");
 }
 system("pause");
 return 0;
}

Sample Output


print pattern c language

No comments :

Post a Comment

Note: Only a member of this blog may post a comment.

Copyright 2017. All Rights Reserved. Privacy Policy / Terms And Conditions / Sitemap / Contact