"Algorithm Notes" Section 2.2-C/C++ Quick Start -> Sequence structure example 1-2-2 Find the sum of two integer numbers (2)

Example 1-2-2 Find the sum of two integer numbers (2)

Title description
Input two integers on the keyboard, and output the sum of these two numbers, that is, your task is to calculate a+b.
Input
Input two integers separated by spaces.
Output
For two integers separated by spaces, sum them.
Sample input Copy
5 6
Sample output Copy
11

#include <stdio.h>
int main()
{
    
    
    int a,b;
    scanf("%d%d",&a,&b);
    printf("%d",a+b);
    return 0;
}

Since scanf input ends with a blank character (ie, space, tab), it doesn’t matter whether you add a space or not

Guess you like

Origin blog.csdn.net/DoMoreSpeakLess/article/details/109733050