Write a program that declares two integer variables. The user must enter their values. The program then calculates their sum, their multiplication, and displays the results.


Difficulty level
This exercise is mostly suitable for students
#include <stdio.h>

int main()
{
    int a ,b ;
    printf("Enter 2 integers: ");
    scanf("%d %d", &a, &b);
    printf("a=%d, b=%d\n", a ,b);
    printf("%d + %d = %d \n", a , b , a+b);
    printf("%d * %d = %d \n", a , b , a*b);
    
    return 0;
}

Back to the list of exercises
Looking for a more challenging exercise, try this one !!
Sum of positive non zero digits