info@tutorialdiary.com

Sunday, May 22, 2016

Solution to Coding/Automata section in AMCAT | Write a C program to print below,when n=4 and s=3

2:18 PM

Share it Please
Below is the question  in AMCAT Automata section

Q.   Write a C program to print below,when n=4 and s=3

3
44
555
555
44
3


Solution to this Question is:

[code]

#include <stdio.h>
int main()
{
   int n=4,s=3;
  for(int i=1;i<n;i++)
  {
      for(int j=1;j<=i;j++)
      printf("%d",s);
      s++;
      printf("\n");
  }
  s--;
   for(int i=n;i>1;i--)
  {
      for(int j=1;j<i;j++)
      printf("%d",s);
      s--;
      printf("\n");
  }
   return 0;
}
[/code]


Rune it online at:


0 comments:

Post a Comment