未定义范围 c++ 需要 int inout

Scope not defined c++ need int inout

本文关键字:int inout 需要 c++ 范围 未定义      更新时间:2023-10-16
#include <iostream>
#include <stdio.h>
int main(void)
{
   printf("Hello, CS 101! n");
   int age{
     printf("How old are you? n")
    };
   printf("OK, you are",scanf(%i,&age),"years old.");

   return 0;
}

我们的作业需要使用scanf和printf来找出用户的年龄,然后打印一条声明,说明他们的年龄。

我们的教授没有复习语法,而是在课堂上给了我们代码,但我离黑板太远了,看不见。这是我自己得到的,但我还没有找到好的 c++ 编码资源。

得到的错误范围未定义,有人可以帮助我。此外,如果有人有很好的资源从头开始学习,那就太好了。这是我第一次编码,谢谢。

我修复了你的代码。希望这是你所追求的:

#include <iostream>
#include <stdio.h>
int main(void)
{
   printf("Hello, CS 101! n");

   // declare age as int
   int age;
   // ask for age 
   printf("How old are you? n");
   // get user input into age
   scanf("%d", &age);
   // display entered age
   printf("OK, you are %d years old.n", age);
   return 0;
}