"Good Programmer's note sharing" Basic use of the scanf function of C language

Source: Internet
Author: User

iOS training------My C language notes, look forward to communicating with you!

#include <stdio.h>intMain () {//define a variable to hold the integer entered by the user    intNumber ; //the scanf function accepts only the address of the variable//The scanf function is a blocking function that waits for the user to enter//after the user has entered, the value entered by the user is assigned to the number variable//function call Completescanf"%d", &Number ); printf ("the value entered by the user is%d\n", number); return 0;}/*prompts the user to enter two integers, calculates and outputs two integers and*/Example: #include<stdio.h>intMain () {//1. Define 2 variables to save the integer entered by the user    intNum1, num2; //2. Prompt the user to enter a 1th integerprintf"Please enter a 1th integer: \ n"); //3. Receive the 1th integer entered by the userscanf"%d", &NUM1); //4. Prompt the user to enter a 2nd integerprintf"Please enter a 2nd integer: \ n"); //5. Receive the 2nd integer entered by the userscanf"%d", &num2); //6. Calculate and, and output    intsum = NUM1 +num2; printf ("%d+%d=%d\n", NUM1, num2, sum); return 0;}

"Good Programmer's note sharing" Basic use of the scanf function of C language

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.