AMCAT Automata Question - Pattern 1

These question was asked in AMCAT Automata Examination. 

AMCAT Automata Coding Question - SimpleWay2Code

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"); 
       
   }
}




Check Out More Questions from AMCAT Automata Test : Click here

This Blog is Hard work !

Can you give me a treat 😌

Post a Comment

0 Comments