mardi 29 septembre 2015

Write a program that prints a trapezoid in Programming in C

Hey guys I am struggling with my program. It should print a trapezoid like this:

ccc

cccc

ccccc

cccccc

This is what i came up with:

int main(){
 int n,m,row,column;
 char c;
 printf("Enter a character: ");
 scanf("%c",&c);

 printf("Enter number of rows\n");
 scanf("%d",&n);

 printf("Enter number of columns\n");
 scanf("%d",&m);

 for ( row = 1 ; row <= n ; row++ )
 {
     for( column = 1 ; column <= m ; column++ ){
             printf("%c",c);
     }
     printf("\n");


 }
 return 0;

}

This above prints this: c = c

n= 4

m=3

ccc

ccc

ccc

ccc

Please help, I have no clue anymore i am frustrated Thank you very much

Aucun commentaire:

Enregistrer un commentaire