How to write a code for sum calculation in C language.

Here is an example of a C language code for finding the sum.

#include <stdio.h>

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

    printf("请输入两个整数:");
    scanf("%d %d", &num1, &num2);

    sum = num1 + num2;

    printf("两个整数的和为:%d\n", sum);

    return 0;
}

After running the program, it will prompt the user to input two integers, then calculate their sum and display the result.

bannerAds