0% found this document useful (0 votes)
30 views6 pages

22-07-24 C Lab

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)
30 views6 pages

22-07-24 C Lab

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/ 6

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

* * *
* * *
* * *
* * *
* * *

#include <stdio.h>

int main() {

int n;

scanf("%d",&n);

for(int i=1;i<=n;i++)
{
for(int j=1;j<=3;j++)
{
printf("* ");
}

printf("\n");
}

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

1 1 1 1 1
2 2 2 2 2
3 3 3 3 3
4 4 4 4 4
5 5 5 5 5

#include <stdio.h>

int main() {

int count =1,n;

scanf("%d",&n);

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

return 0;
}
=======================================================================
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5

#include <stdio.h>

int main() {

int n,c,count=1;
scanf("%d%d",&n,&c);

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

printf("\n");
}

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

1 3 5 7 9
11 13 15 17 19
21 23 25 27 29
31 33 35 37 39

#include <stdio.h>

int main() {

int r,c,count=1;
scanf("%d%d",&r,&c);

for(int i=1;i<=r;i++)
{
for(int j=1;j<=c;j++)
{

printf("%3d",count);

count=count+2;
}

printf("\n");
}

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

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

#include <stdio.h>

int main() {
int r,c;
scanf("%d%d",&r,&c);

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

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

return 0;
)
==================================================================

2 4 6 8 10
12 14 16 18 20
22 24 26 28 30
32 34 36 38 40
42 44 46 48 50

#include <stdio.h>

int main() {

int r,c,count=2;
scanf("%d%d",&r,&c);

for(int i=1;i<=r;i++)
{
for(int j=1;j<=c;j++)
{

printf("%3d",count);

count=count+2;
}

printf("\n");
}

return 0;
}
======================================================================
1 1 2 1 3 1
1 2 2 2 3 2
1 3 2 3 3 3
1 4 2 4 3 4
1 5 2 5 3 5

int main() {
int r,c,num=1;

scanf("%d%d",&r,&c);

for(int i=1;i<=r;i++)

{ num=1;

for(int j=1;j<=c;j++)
{

if(j%2==0)
{
printf("%3d ",i);

}
else{
printf("%3d ",num++);
}
}
printf("\n");
}

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

1 2 3 4 5
2 4 6 8 10
3 6 9 12 15
4 8 12 16 20
5 10 15 20 25

#include <stdio.h>

int main() {

int r,c,count=1;

scanf("%d%d",&r,&c);

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

return 0;
}
==========================================================================
1 6 11 16 21
2 7 12 17 22
3 8 13 18 23
4 9 14 19 24
5 10 15 20 25

#include <stdio.h>

int main() {

int r,c,add=5,count=1;

scanf("%d%d",&r,&c);

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

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

#include <stdio.h>

int main() {

int r,c;
scanf("%d%d",&r,&c);
for(int i=1;i<=r;i++)
{
for(int j=1;j<=c;j++)
{
if((i+j)%2==0)
{
printf("0 ");
}
else
{
printf("1 ");
}
}

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

You might also like