07-26-2023, 03:46 PM
Example:
#include <stdio.h>
int main() {
short int a = 1000;
short int b = 200;
// Addition
short int sum = a + b;
printf("Sum: %d\n", sum);
// Subtraction
short int difference = a - b;
printf("Difference: %d\n", difference);
// Multiplication
short int product = a * b;
printf("Product: %d\n", product);
// Division
short int quotient = a / b;
printf("Quotient: %d\n", quotient);
return 0;
}
Explanation:
Explanation: In this example, we perform basic arithmetic operations (addition, subtraction, multiplication, and division) using short int variables. The result of each operation is stored in a short int variable and then printed using the %d format specifier in printf.
#include <stdio.h>
int main() {
short int a = 1000;
short int b = 200;
// Addition
short int sum = a + b;
printf("Sum: %d\n", sum);
// Subtraction
short int difference = a - b;
printf("Difference: %d\n", difference);
// Multiplication
short int product = a * b;
printf("Product: %d\n", product);
// Division
short int quotient = a / b;
printf("Quotient: %d\n", quotient);
return 0;
}
Explanation:
Explanation: In this example, we perform basic arithmetic operations (addition, subtraction, multiplication, and division) using short int variables. The result of each operation is stored in a short int variable and then printed using the %d format specifier in printf.