california

#include <stdio.h>

int main() {
    int num1, num2, sum;

    printf("Enter first number: ");
    scanf("%d", &num1);

    printf("Enter second number: ");
    scanf("%d", &num2);

    sum = num1 + num2;

    printf("Sum of %d and %d is %d\n", num1, num2, sum);

    return 0;
}

Explanation:

  • #include <stdio.h>: Includes the standard input-output library in C, allowing for input/output operations.
  • int main() { ... }: The main function of the program where execution begins. It returns an integer.
  • int num1, num2, sum;: Declaration of three integer variables num1, num2, and sum without assigning any values.
  • printf("Enter first number: ");: Displays a message prompting the user to enter the first number.
  • scanf("%d", &num1);: Reads an integer input from the user and stores it in the variable num1.
  • printf("Enter second number: ");: Displays a message prompting the user to enter the second number.
  • scanf("%d", &num2);: Reads an integer input from the user and stores it in the variable num2.
  • sum = num1 + num2;: Calculates the sum of num1 and num2 and assigns the result to the variable sum.
  • printf("Sum of %d and %d is %d\n", num1, num2, sum);: Prints the sum of num1 and num2 using the printf function with format specifiers %d for integers.
  • return 0;: Indicates the successful termination of the main() function with a return value of 0, indicating the program ran without errors.