程序中的这个杂散错误是什么

时间:2019-09-23 15:08:41

标签: windows-10

代码:

#include<stdio.h>
#include<conio.h>
int main()
{
    int a,b,c;
    printf("addition of two numbers\n");
    scanf("%d%d",&a,&b);
    c = a + b;
    printf("%d",c,\n);
    printf("subtraction of two numbers\n");            
    scanf("%d%d",&a,&b);
    c = a - b;
    printf("%d",c \n);
    return 0;


}

错误:

9   2   C:\Users\Yash\Documents\c.3.cpp [Error] stray '\' in program
13  2   C:\Users\Yash\Documents\c.3.cpp [Error] stray '\' in program
C:\Users\Yash\Documents\c.3.cpp In function 'int main()':
9   17  C:\Users\Yash\Documents\c.3.cpp [Error] 'n' was not declared in this scope
13  17  C:\Users\Yash\Documents\c.3.cpp [Error] expected ')' before 'n'

1 个答案:

答案 0 :(得分:-1)

您的两个printf()命令:

printf("%d",c,\n);

printf("%d",c \n);

在换行符周围缺少引号(一个逗号)。他们应该看起来像这样:

printf("%d \n",c);