c program for airthmetic operators
#include <stdio.h>
int main() {
int a = 10, b = 4, result;
result = a + b;
printf("a + b = %d\n", result);
result = a - b;
printf("a - b = %d\n", result);
result = a * b;
printf("a * b = %d\n", result);
result = a / b;
printf("a / b = %d\n", result);
result = a % b;
printf("a %% b = %d\n", result);
return 0;
}
Explanation:
- The program includes the standard input-output library, stdio.h
.
- In the main
function, integer variables a
, b
, and result
are declared and initialized with the values 10, 4, and 0, respectively.
- The arithmetic operations are performed using the variables a
and b
, and the results are stored in the result
variable.
- The printf
function is used to display the results of the arithmetic operations.
- The %d
format specifier is used to print the integer values of the results.
- The program ends with a return 0;
statement to indicate successful execution.