# How to Add Two Constant Numbers in C

## Adding Two Constant Number in C

You can add two constant integers or floating-point numbers using C in many ways. You can implement it in several ways.

Two add two different constant number defined by the system we will obviously use the main() function.  Here you can use the only main() function or int main() method to do this. Just keep in mind, if you use int main(), then you have to use the return 0; statement for the program simplicity.

After defining the main function we will declare two or three variables for keeping the constant number and then finally we will use the printf function for displaying the result. And for the addition, we will simply use the arithmetic addition operators. Let’s see some examples:

Example:

``````#include <stdio.h>
int main() {
int number;
float amount;

number = 15 + 13;
amount = 14.60 + 33.65;

printf("Number is: %d\n", number);
printf("Amount is: %0.2f\n", amount);

return 0;
}
``````

Output:

Write the above code in a text editor then try to compile with any of supported C compiler, then run you should get following output.

Example Explanation:

In the C program above, we have included the standard input/output library of C programming called stdio.h. Then we have used the main() function. The main function actually comes from the library that we have included in the 1st line. We have used the int keyword before the main function, it means the function will return an integer value to the OS.

The pair of parentheses after the main function () indicates there are no arguments in the main function. Arguments are usually used for calling the main function by others function for example self-defined function. Here we didn’t use any other function that’s why we kept the argument space empty.

Then in the main function, we have declared the two variables, one of the integer variable called number and another one is a floating-point variable called amount.

Then we have performed arithmetic additional operations between two integer number and floating-point number and stored them gradually in the number and amount variable. Here the two variables will store the result of the two numbers.

Finally, to display on the screen we have used the printf function comes from the stdio.h standard library.