C程序以打印的整数(用户输入的)

C程序以打印的整数(用户输入的)

了解这个例子中,你应该具有知识的下列 C程序 的主题:

  • C变量,常量和文本
  • C数据的类型
  • C输入输出(I/O)

程序打印的整数

#include <stdio.h>
int main() {   
    int number;
   
    printf("Enter an integer: ");  
    
    // reads and stores input
    scanf("%d", &number);

    // displays output
    printf("You entered: %d", number);
    
    return 0;
}

运行代码

Output

Enter an integer: 25
You entered: 25

In this program, an integer variable number is declared.

int number;

Then, the user is asked to enter an integer number. This number is stored in the number variable.

printf("Enter an integer: ");
scanf("%d", &number);

Finally, the value stored in number is displayed on the screen using printf().

printf("You entered: %d", number);

本文来自投稿,不代表亲测学习网立场,如若转载,请注明出处:https://www.qince.net/c-print.html

郑重声明:

本站所有内容均由互联网收集整理、网友上传,并且以计算机技术研究交流为目的,仅供大家参考、学习,不存在任何商业目的与商业用途。 若您需要商业运营或用于其他商业活动,请您购买正版授权并合法使用。

我们不承担任何技术及版权问题,且不对任何资源负法律责任。

如遇到资源无法下载,请点击这里失效报错。失效报错提交后记得查看你的留言信息,24小时之内反馈信息。

如有侵犯您的版权,请给我们私信,我们会尽快处理,并诚恳的向你道歉!

(0)
上一篇 2023年10月12日 上午12:05
下一篇 2023年10月12日 下午8:18

猜你喜欢