In this exercise section of the tutorial we will write some basic C program.

Don't worry if you don't understand the code in one go. We will talk in detail about the program in later part of the tutorial.

This is fairly simple. All we have to do is use the `printf()`

function.

```
#include <stdio.h>
int main(void)
{
printf("We are learning C.");
return 0;
}
```

Try this yourself.

We will create three integer variables `a`

, `b`

and `sum`

.

We use variable to store value in C.

And since the variables will store integer value so, we will set the date type as `int`

.

Data type of a variable tells us about the type of value stored in the variable.

```
#include <stdio.h>
int main(void)
{
int a = 10;
int b = 20;
int sum = a + b;
printf("Sum: %d", sum);
return 0;
}
```

Output:

```
Sum: 30
```

```
int a = 10;
```

In the above line we have created variable named `a`

and its type is `int`

which means we can store integer values.

Then we have assigned value 10 using the `=`

assignment operator.

And we have ended the statement using the `;`

semicolon.

Similarly, we have created another integer variable `b`

and assigned an integer value 20.

```
int b = 20;
```

Next we have the third integer variable `sum`

that holds the sum of the two integer value stored in variable `a`

and `b`

. We are adding the value using the `+`

addition operator.

```
int sum = a + b;
```

Finally we are printing the result using the `printf()`

function.

```
printf("Sum: %d", sum);
```

The `%d`

in the first argument `"Sum: %d"`

of `printf()`

function tells the compiler that the second argument `sum`

is printed as a decimal number.

- Octal to Decimal conversion of an integer number Conversion
- How to install RabbitMQ on Mac using Homebrew How to Mac
- What is EMI? Money
- What is Recurring Deposit? Money
- What is Fixed Deposit? Money
- Sum of Products and Product of Sums Boolean Algebra
- How to install Apache, MySQL, PHP on macOS Mojave 10.14 How to Mac
- Bubble Sort Sorting Algorithm
- Product of Sums reduction using Karnaugh Map Boolean Algebra
- Sum of Products reduction using Karnaugh Map Boolean Algebra