﻿ C Program: Produce the following table of values - w3resource

# C Exercises: Produce the following table of values

## C Basic Declarations and Expressions: Exercise-79 with Solution

Write a C program using looping to produce the following table of values.

```x       x+2     x+4     x+6
--------------------------------
1       3       5       7
4       6       8       10
7       9       11      13
10      12      14      16
13      15      17      19
```

Sample Solution:

C Code:

``````#include<stdio.h>
int main()
{
int x; // Declare variable x

printf("x\tx+2\tx+4\tx+6\n\n");
printf("---------------------------\n");

// Loop to generate and print table values
for(x=1; x<=15; x+=3)
printf("%d\t%d\t%d\t%d\n", x, (x+2), (x+4), (x+6));

return 0; // Indicate successful program execution
}
``````

Sample Output:

```x	x+2	x+4	x+6

---------------------------
1	3	5	7
4	6	8	10
7	9	11	13
10	12	14	16
13	15	17	19
```

Flowchart:

C programming Code Editor:

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.

﻿