These question was asked in AMCAT Automata Examination.
Ques: To print the pattern like for n=3 the program should print
1 1 1 2
3 2 2 2
3 3 3 4
#include<stdio.h>
int main() {
int n=3,c=n-1,i;
for(i=1;i<=n;i++)
{
if(i%2==0){
printf("%d",c++);
}
for(int j=1;j<=n;j++) {
printf("%d",i);
}
if(i%2!=0){
printf("%d",c++);
}
printf("\n");
}
}
This Blog is Hard work !
Can you give me a treat 😌
0 Comments