C %d
#include <stdio.h>
int main() {
int a = 5;
int b = 10;
int c;
c = a + b;
printf("The sum of a and b is: %d\n", c);
return 0;
}
Explanation:
- The program begins by including the standard input-output header file, <stdio.h>
, which provides functions like printf
and scanf
.
- Inside the main()
function, three integer variables are declared: a
, b
, and c
.
- a
is assigned the value 5
, and b
is assigned the value 10
.
- A third variable c
is declared to store the sum of a
and b
.
- The sum of a
and b
is calculated and stored in variable c
using the assignment operator =
.
- The printf
function is used to display the sum of a
and b
by printing "The sum of a and b is: %d\n"
along with the value stored in variable c
.
- The \n
in the format string represents a newline character, moving the output to the next line.
- Finally, the return 0;
statement indicates that the program execution was successful, and 0
is returned to the operating system.