1
01
101
0101
10101
Answers were Sorted based on User's Feedback
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 |
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 |
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 |
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 |
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?
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....
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.
What experience have you had in working with field forces?
why only j2me is used for mobile???
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...
basic difference between run time and compile time polymorphism
What are the benefits of using interface accept multiple inheritance concept?
Derive the equation that links voltage, charge and capacitance.
what is inheritance
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?