0

Why my coding is not working?

#include <stdio.h> int main() { int i, j, rows; char ch; printf("enter the number of rows\n"); scanf("%d",&rows); printf("enter which character you want in pyramid \n"); scanf("%c",&ch); for(i=1;i<=rows;i++) { for(j=1;j<=i;j++) { printf("%c\ ",ch); } printf("\n"); }; return 0; }

16th Jul 2018, 4:06 PM
Shubham Patel
Shubham Patel - avatar
1 Odpowiedź
+ 3
It is working, you just have to enter the count and char adjacent to each other like this: 9c ...Gives you 9 rows of "c " Note, it looks like scanf isn't really suitable for this purpose: https://stackoverflow.com/questions/26583717/how-to-scanf-only-integer
16th Jul 2018, 4:55 PM
Kirk Schafer
Kirk Schafer - avatar