☞ C program to print following pattern.
1
3*2
4*5*6
10*9*8*7
#include<stdio.h>
int main() {
int n,i,j,k=1,kk;
scanf("%d",&n);
for(i=1;i<=n;i++){
if(i%2==0){
kk=k+i;
k=kk;
for(j=1;j<=i;j++){
printf("%d",--kk);
if(j!=i)
printf("*");
}
}
else{
for(j=1;j<=i;j++){
printf("%d",k++);
if(j!=i)
printf("*");
}
}
printf("\n");
}
}
Sample Input
4
Sample Output
1
3*2
4*5*6
10*9*8*7
For mini projects click here
CSE Materials click here
1
3*2
4*5*6
10*9*8*7
#include<stdio.h>
int main() {
int n,i,j,k=1,kk;
scanf("%d",&n);
for(i=1;i<=n;i++){
if(i%2==0){
kk=k+i;
k=kk;
for(j=1;j<=i;j++){
printf("%d",--kk);
if(j!=i)
printf("*");
}
}
else{
for(j=1;j<=i;j++){
printf("%d",k++);
if(j!=i)
printf("*");
}
}
printf("\n");
}
}
Sample Input
4
Sample Output
1
3*2
4*5*6
10*9*8*7
For mini projects click here
CSE Materials click here