1
01
101
0101
10101

Answers were Sorted based on User's Feedback



1 01 101 0101 10101..

Answer / best in the world

#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,k;
for(i=1;i<=5;i++)
{
for(j=1;j<=i;j++)
{
printf("%d ",(i+j+1)%2);
}
printf("\n");
}
getch();
}




THIS IS THE BEST SOLUTION IN THE WORLD

Is This Answer Correct ?    59 Yes 11 No

1 01 101 0101 10101..

Answer / suket

Mine doesn't require 3 variables:
#include<stdio.h>
int main()
{
int i,j,rows;
printf("Enter no. of rows: ");
scanf("%d",&rows);

printf("Here's your pattern: \n");
for (i=1;i<=rows;i++)
{
for(j=i;j!=0;)
{
if(j%2==0)
{
printf("01");
j=j-2;
}
else
{
printf("1");
j--;
}
}
printf("\n");
}
return 0;
}

Is This Answer Correct ?    7 Yes 4 No

1 01 101 0101 10101..

Answer / guriya kumari

#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,k;
for(i=1;i<=5;i++)
{
for(j=1;j<=i;j++)
{
if(i%2==0)
{
if(j%2==0)
{
k=1;
printf("%d",k);
}
else
{
k=0;
printf("%d",k);
}
}
else
{
if(j%2==0)
{
k=0;
printf("%d",k);
}
else
{
k=1;
printf("%d",k);
}
}
}
printf("\n");
}
}

Is This Answer Correct ?    7 Yes 6 No

1 01 101 0101 10101..

Answer / krishna anil dadge

#include<iostream>
using namespace std;
int main()
{
for(int i=1;i<=5;i++)
{
for(int j=1;j<=i;j++)
{
if((i+j)%2==0)
{
cout<<"1";
}
else
{
cout<<"0";
}
}
cout<<endl;
}
return 0;
}

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More Engineering AllOther Interview Questions

the game of tic-tac-toe is being played between two players. only the last mark to be placed in the game. who will win the game?

8 Answers   Infosys,


how am i supposed to convert a class program in C++ to Matlab? Do i also need to make classes in matlab too or I can do it without making classes???Can somebody help....

0 Answers  


Write a C program to solve the quadratic equation ax^2+bx+c=0. A quadratic equation has two roots which are given by the following two formulas: root1= -b+sqrt(b^2-4*a*c)/2*a root1= -b-sqrt(b^2-4*a*c)/2*a The program request the user for input a,b,c and the output will be root1 and root2.

1 Answers  


What experience have you had in working with field forces?

0 Answers  


why only j2me is used for mobile???

0 Answers  






I am student pursuing B.E/B.tech in Computers 8'th sem.What should i do for a better carrier.Plz suggest other than programming languages.Is the ERP a better one to do?plz help...

0 Answers  


basic difference between run time and compile time polymorphism

3 Answers  


What are the benefits of using interface accept multiple inheritance concept?

2 Answers   IBM,


Derive the equation that links voltage, charge and capacitance.

0 Answers  


what is inheritance

6 Answers   TCS,


Prove that in a self-complementing code the sum of the weights must be 9?

7 Answers   IIIT, Mind Tree, TCS,


A person was fined for exceeding the speed limit by 10mph.another person was also fined for exceeding the same speed limit by twice the same if the second person was traveling at a speed of 35 mph. find the speed limit?

1 Answers   TCS,


Categories
  • Civil Engineering Interview Questions Civil Engineering (5085)
  • Mechanical Engineering Interview Questions Mechanical Engineering (4451)
  • Electrical Engineering Interview Questions Electrical Engineering (16632)
  • Electronics Communications Interview Questions Electronics Communications (3918)
  • Chemical Engineering Interview Questions Chemical Engineering (1095)
  • Aeronautical Engineering Interview Questions Aeronautical Engineering (239)
  • Bio Engineering Interview Questions Bio Engineering (96)
  • Metallurgy Interview Questions Metallurgy (361)
  • Industrial Engineering Interview Questions Industrial Engineering (259)
  • Instrumentation Interview Questions Instrumentation (3014)
  • Automobile Engineering Interview Questions Automobile Engineering (332)
  • Mechatronics Engineering Interview Questions Mechatronics Engineering (97)
  • Marine Engineering Interview Questions Marine Engineering (124)
  • Power Plant Engineering Interview Questions Power Plant Engineering (172)
  • Textile Engineering Interview Questions Textile Engineering (575)
  • Production Engineering Interview Questions Production Engineering (25)
  • Satellite Systems Engineering Interview Questions Satellite Systems Engineering (106)
  • Engineering AllOther Interview Questions Engineering AllOther (1379)