Thursday, April 3, 2014

Tuesday, April 1, 2014

Nested 2 Types Symbol Pyramid

Q. Write a C program to print the following nested 2 types different symbol pyramid as:

@
#
@@
##
@@@
###

Ans.

/*c program for nested 2 types different symbol pyramid*/
#include<stdio.h>
int main()
{
 int num,r,c,z;
 printf("Enter Maximum Loop Repeat No. : ");
 scanf("%d", &num);

 for(r=1; r<=num; r++)
 {
  for(c=1; c<=2; c++)
  {
   if(c%2==0)
   {
    for(z=1; z<=r; z++)
       printf("#");
   }
   else
   {
    for(z=1; z<=r; z++)
       printf("@");
   }
   printf("\n");
  }
 }
 getch();
 return 0;
}


/*************************************************************

The output of above program would be
*************************************************************/


Figure: Screen shot for Nested 2 Types Symbol Pyramid C Program



Related Programs: