Asked inCognizant,GenC

Write program on 1 01 101 1010 10101

AnswerBot
1y

The program prints a pattern of alternating 1s and 0s in a specific sequence.

  • Use a loop to iterate through the given sequence of numbers

  • Inside the loop, check the length of each number and print the c...read more

Sonali Chavan
3y

In C lang,

#include<stdio.h>

int main()

{

int i,j;

int n=5;

for(i=0;i<n;i++)

{

for(j=0;j<i;j++)

{

if((i+j)%2==0){printf("0");

}

else{

printf("1");

}

}

printf("\n");

}

return 0;

}

Help your peers!
Add answer anonymously...
Cognizant GenC Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter