0% found this document useful (0 votes)
12 views3 pages

Nested Loops

The document contains three C programs that demonstrate different patterns using nested loops. The first program prints a square of asterisks, the second prints 'A' on the diagonal and 'F' elsewhere, and the third prints a checkerboard pattern of '1's and '0's based on the sum of the row and column indices. Each program is designed to create a 4x4 grid based on the specified logic.

Uploaded by

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

Nested Loops

The document contains three C programs that demonstrate different patterns using nested loops. The first program prints a square of asterisks, the second prints 'A' on the diagonal and 'F' elsewhere, and the third prints a checkerboard pattern of '1's and '0's based on the sum of the row and column indices. Each program is designed to create a 4x4 grid based on the specified logic.

Uploaded by

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

1.

#include<stdio.h>

void main() {

//variables

int row, col, size = 4;

//loop for the row

for (row = 1; row <= size; row++) {

for (col = 1; col <= size; col++) {

printf("* ");

printf("\n");

2.
#include<stdio.h>

void main() {

//variables

int row, col, size = 4;

//loop for the row

for (row = 1; row <= size; row++) {

for (col = 1; col <= size; col++) {

if (row == col) {

printf("A ");
}

else {

printf("F ");

printf("\n");

3.
#include<stdio.h>

void main() {

//variables

int row, col, size = 4;

//loop for the row

for (row = 1; row <= size; row++) {

for (col = 1; col <= size; col++) {

if ((row + col)%2 == 0) {

printf("1 ");

else {

printf("0 ");

printf("\n");

}
}

You might also like