C Programming

C Programming


Reverse L-Shape Pyramid

Posted: 27 Aug 2013 01:55 AM PDT

Q. Write a C program to print the following Reverse L-Shape pyramid as:

*************
*
*
*
*
*
*
*


Ans.

/*c program for reverse L-shape pyramid*/
#include<stdio.h>
int main()
{
 int c;

 for(c=1; c<=13; c++)
    printf("*");
 for(c=1; c<=7; c++)
    printf("*\n");
 getch();
 return 0;
}

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


Output of reverse L-Shape Pyramid C program
Figure : Screen shot for reverse L-Shape pyramid C program



C Star Triangle

Posted: 27 Aug 2013 01:22 AM PDT

Q. Write a C program to make the following star triangle as:

*
**
**
**
******

Ans.

/*c program for star triangle design*/
#include<stdio.h>
int main()
{
 int r,c,n;
 printf("*\n");

 for(r=1; r<=4; r++)
 {
  if(r<=3)
  {
    for(c=1; c<=2; c++)
        printf("*");
  }
  else
  {
    for(c=1; c<=6; c++)
        printf("*");
  }
  printf("\n");
 }
 getch();
 return 0;
}

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


Output of star triangle pyramid C program
Figure : Screen shot for star triangle C program



Post a Comment