0% found this document useful (0 votes)
11 views5 pages

23-07-2024 Lab C

Uploaded by

cujohozu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views5 pages

23-07-2024 Lab C

Uploaded by

cujohozu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 5

1

2 3
4 5 6
7 8 9 10
11 12 13 14 15

#include <stdio.h>

int main() {

int n,count=1;

scanf("%d",&n);

for(int i=1;i<=n;i++)
{
for(int j=1;j<=i;j++)
{
printf("%3d",count++);
}
printf("\n");
}

return 0;
}

================================================================

1
2 3
3 4 5
4 5 6 7
5 6 7 8 9

#include <stdio.h>

int main() {

int n,count=0,sum=0;

scanf("%d",&n);

for(int i=1;i<=n;i++)
{
for(int j=1;j<=i;j++)
{ sum=count+j;
printf("%3d",sum);

}
count++;
printf("\n");
}

return 0;
}
=======================================================================
0
1 0
0 1 0
1 0 1 0
0 1 0 1 0
1 0 1 0 1 0

#include <stdio.h>

int main() {

int n,count=1;

scanf("%d",&n);

for(int i=1;i<=n;i++)
{
for(int j=1;j<=i;j++)
{
if((i+j)%2==0)
{
printf("0 ");

}
else printf("1 ");
}
printf("\n");
}

return 0;
}
============================================================================

0
0 1
0 1 1
0 1 1 2
0 1 1 2 3

#include <stdio.h>

int main() {

int n,a=2;

scanf("%d",&n);

for(int i=1;i<=n;i++)
{ a=2;
for(int j=1;j<=i;j++)
{
if(j==1)
{
printf("0 ");
}
else if(j==2 || j==3)
{
printf("1 ");
}

else printf("%d ",a++);

}
printf("\n");
}
=================================================================================

0
0 1
0 1 0
0 1 0 1
0 1 0 1 0
0 1 0 1 0 1

#include <stdio.h>

int main() {

int n,count=1;

scanf("%d",&n);

for(int i=1;i<=n;i++)
{
for(int j=1;j<=i;j++)
{
if((j)%2==0)
{
printf("1 ");

}
else printf("0 ");
}
printf("\n");
}

return 0;
}
===================================================================================
==

1
1 2
3 5 8
13 21 34 55

#include <stdio.h>

int main() {
int n,num1=0,num2=1,result=0;

scanf("%d",&n);

for(int i=1;i<=n;i++)
{
for(int j=1;j<=i;j++)
{
printf("%d ",num2);
result = num1+num2;
num1=num2;
num2=result;
}
printf("\n");
}

return 0;
}

===================================================================================
===

A
B A
C B A
D C B A
E D C B A

#include <stdio.h>

int main() {
int n,count=0;
char ch = 'A' ;

scanf("%d",&n);

for(int i=1;i<=n;i++)
{
count=i-1;
for(int j=1;j<=i;j++)
{

printf("%c ",ch+count);
count--;

printf("\n");
}

return 0;
}
===============================================================================

// 1
// 2 6
// 3 7 10
// 4 8 11 13
// 5 9 12 14 15

#include <stdio.h>

int main() {
int n,count=4,val;

scanf("%d",&n);
for(int i=1;i<=n;i++)
{ count=4;
val=i;
for(int j=1;j<=i;j++)
{
printf("%3d",val);
val=val+count;
count--;
}
printf("\n");
}
return 0;
}
===================================================================================
==

You might also like