RUN

Sum of two numbers in C

Read two numbers with scanf and print their sum. Press Run to try it, then change the code and run it again.

main.c

#include <stdio.h>

int main(void) {
    int a, b;
    printf("Enter two numbers: ");
    scanf("%d %d", &a, &b);
    printf("%d + %d = %d\n", a, b, a + b);
    return 0;
}
Output

Press Run to see the output.

More C examples

Open the full C online compiler →