#include<stdio.h>
#include<conio.h>
void main()
{
int i=1,a,b,c,choice;
do
{
printf("enter any two numbers\n");
scanf("%d%d",&a,&b);
printf("pressing one add the two numbers\nenter one if you want to\n");
scanf("%d",&choice);
switch(choice)
{
case 1:
{
c=a+b;
printf("the sum of the entered numbers%.1f\n\n:",c);
break;
}
default:
printf("you have entered an invalid");
break;
}
clrscr();
}
while(i==1);
getch();
}
Run Code Online (Sandbox Code Playgroud)
我不知道是因为我的同学使用的是turbo c,对我来说很好,我使用的是dev c ++,但看起来像clrscr(); 请编译器帮助未知。
您的同学正在DOS下编程,显然您没有... conio.hTurbo C和DOS附带...所以,删除行
#include<conio.h>
Run Code Online (Sandbox Code Playgroud)
和
clrscr();
Run Code Online (Sandbox Code Playgroud)
和
getch();
Run Code Online (Sandbox Code Playgroud)
使您的程序编译...
...,请勿%.1f用于打印int。
...并且main()必须返回int
*并且不要从你的同学那里抄袭...他似乎陷入了石器时代*