当我读取第一个值时,它没有取值并继续进入循环。当我按“esc”和“enter”然后它将读取第二个数字,但没有取第二个数字,程序执行完成..
int main (int argc, const char * argv[])
{
// insert code here...
int firstNumber = 0,secondNumber = 0,result = 0;
printf("\nEnter first number");
scanf("%d", &firstNumber);
printf("\nEnter second number");
scanf("%d", &secondNumber);
result = firstNumber+secondNumber;
printf("\nResult is %d", result);
return 0;
}
答案 0 :(得分:0)
您的代码有效,请再次查看!您可以稍微修改它以在新行上输入数字
int first = 0, second = 0, result = 0;
printf("Enter the first number: \n");
scanf("%d",&first);
printf("Enter the second number: \n");
scanf("%d",&second);
result = first + second;
printf("Result is: %d \n", result);
cout << "\nEnd";
return 0;