Ques. Print the following Pattern and get the Output.
1
3*2
4*5*6
10*9*8*7
11*12*13*14*15
#include<stdio.h>
int main() {
int i,j,n,count=0,k=0;
printf("Enter N:\n");
scanf("%d",&n);
for(i=1;i<=n;i++) {
count=k;
for(j=1;j<=i;j++) {
if(i%2==0) {
printf("%d",count+i);
count=count-1;
if(j!=i){
printf("*");
}
k++;
}
else {
count=count+1;
printf("%d",count);
if(j!=i){
printf("*");
}
k++;
}
}
printf("\n");
}
}
Check Out More Questions from AMCAT Automata Test : Click here
1
3*2
4*5*6
10*9*8*7
11*12*13*14*15
#include<stdio.h>
int main() {
int i,j,n,count=0,k=0;
printf("Enter N:\n");
scanf("%d",&n);
for(i=1;i<=n;i++) {
count=k;
for(j=1;j<=i;j++) {
if(i%2==0) {
printf("%d",count+i);
count=count-1;
if(j!=i){
printf("*");
}
k++;
}
else {
count=count+1;
printf("%d",count);
if(j!=i){
printf("*");
}
k++;
}
}
printf("\n");
}
}
Check Out More Questions from AMCAT Automata Test : Click here
This Blog is Hard work !
Can you give me a treat 😌
0 Comments