#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,k=0,l;
clrscr();
for(i=1;i<=5;i++)
{
for(j=1;j<=i;j++)
{
k++;
printf("%d ",k%2);
}
for(l=i;l<=4;l++)
{
k++;
}
printf("\n");
}
getch();
}
Chat with our AI personalities
#include <iostream>
using namespace std;
void printTriangle(int iterations)
{
for(int i = 0; i < iterations; i++)
{
cout << "1";
for(int j = 0; j < i; j++)
cout << "01";
cout << endl;
}
}
int main()
{
printTriangle(4);
return 0;
}
#include
#include
void main()
{
int j,n,i=1;
clrscr();
printf("Enter How Many Times:");
scanf("%d",&n);
for(j=1;j<=n;j++)
{
printf("%d",i);
if(i==1)
i=0;
else
i=1;
}
getch();
}
output:
Enter How Many Times:10
1010101010
echo 'print a pattern'
Q.1 Write a program to print first ten odd natural numbers. Q.2 Write a program to input a number. Print their table. Q.3 Write a function to print a factorial value.
write a program to print the series 1/12+1/22+.........+1/n2 ?
This is a directive, not a question.
#include