0% found this document useful (0 votes)
5 views

Assignment VI - Programming C

assignment vi_programming c

Uploaded by

Thomas Harvey
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)
5 views

Assignment VI - Programming C

assignment vi_programming c

Uploaded by

Thomas Harvey
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

01.

Write a C program to display the following:


1
12
123
1234
12345
123456
1234567
12345678
123456789

#include <stdio.h>

int main() {

// Loop for each line

for (int i = 1; i <= 9; i++) {

// Loop to print numbers in each line

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

printf("%d", j);

// Move to the next line after each row is printed

printf("\n");

return 0;

02. Write a C program to display the following:


1
123
12345
1234567
123456789

#include <stdio.h>

int main() {
// Loop for each line

for (int i = 1; i <= 9; i += 2) {

// Loop to print numbers in each line

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

printf("%d", j);

// Move to the next line after each row is printed

printf("\n");

return 0;

03. Write a C program to display the following:


2
456
6 7 8 9 10
8 9 10 11 12 13 14
10 11 12 13 14 15 16 17 18

#include <stdio.h>

int main() {

int start = 2;

// Loop for each line

for (int i = 1; i <= 5; i++) {

// Determine the number of elements in the current line

int numElements = 2 * i - 1;

// Loop to print numbers in each line

for (int j = 0; j < numElements; j++) {

printf("%d ", start + j);


}

// Move to the next line after each row is printed

printf("\n");

// Update the start value for the next row

start += 2;

return 0;

You might also like