Code in c to print 2*N lines in the manner shown below for a given integer N.
1
2*2
3*3*3
4*4*4*4
4*4*4*4
3*3*3
2*2
1
Answers
Answered by
8
Answer:
#include <stdio.h>
int main(void) {
int n;
scanf("%d",&n);
for(int i=1;i<=n;i++){
for(int j=1;j<=i;j++){
i == j ? printf("%d",i) : printf("%d*",i);
}
printf("\n");
}
for(int i=n;i>=1;i--){
for(int j=1;j<=i;j++){
i == j ? printf("%d",i) : printf("%d*",i);
}
printf("\n");
}
return 0;
}
Explanation:
Similar questions