Control structures are fundamental building blocks of programming and allow programs to make decisions and repeat actions based on various conditions. By using control structures, programs can be made more efficient, flexible, and powerful.
Program:
#include <stdio.h>
int main() {
int num1, num2, choice, sum, diff, greater;
printf("Enter two integer numbers: ");
scanf("%d %d", &num1, &num2);
printf("Choose an operation:\n");
printf("1. Sum\n");
printf("2. Difference\n");
printf("3. Greater\n");
scanf("%d", &choice);
switch(choice) {
case 1:
sum = num1 + num2;
printf("Sum: %d\n", sum);
break;
case 2:
diff = num1 - num2;
printf("Difference: %d\n", diff);
break;
case 3:
greater = (num1 > num2) ? num1 : num2;
printf("Greater: %d\n", greater);
break;
default:
printf("Invalid choice\n");
break;
}
return 0;
}