c語言怎麼實現迴圈加減乘除,C語言怎麼實現迴圈加減乘除

2021-03-03 20:56:10 字數 1121 閱讀 5055

1樓:0星隕

對判斷條件flag賦值語句要放在while裡面 不然while不會跳出來的 而且幹嘛寫這麼多的return 0,只保留最後乙個就好了

用c語言寫乙個只有加減乘除的計算器,它可以多次輸入,直到使用者想結束再退出程式。

2樓:幻想秘境

#include //望採納!!!

int main (void)

case '-':

case '/':

case '*':

default:

}fflush(stdin,null);

printf("計算完畢!是否再次使用?y/n:");

scanf ("%c",&yn);

if (yn=='y' || yn=='y')printf("感謝使用本計算器!本次服務到此結束!\n");

break;

}while (1);}

3樓:匿名使用者

#include

#include

int main(void)

else

break;

default:printf("unknown operator!\n");

}printf("do you want to continue(y/n or y/n?)");

scanf(" %c",&reply);//%c前有一空格}while(reply=='y'||reply=='y');

printf("program is over!\n");

return 0;

}注意一定要有空格,否則程式無法正常執行

4樓:你你名字哈哈

# include

int main()

case 2:

else

}case 3:

case 4:

}printf("是否繼續\n");

printf("繼續按y\n");

scanf(" %c", &ch);

}else

} while ('y'==ch||'y'==ch);

return 0;}

用c語言寫可以加減乘除的計算器,可迴圈的

李小宇 學了十天寫出的第一個小作品 include int main else if c else if c else if c else else return 0 首先,scanf f c f a t b 這句有錯,缺逗號。應改為scanf f c f a,t,b 其次,if get 這句有錯。...

幫我用C編可以進行加減乘除的程式

哦哦 還有更具體點兒的要求嗎?我可以嘗試編寫,用c 編乙個加減乘除的程式 謝了 include int main while flag 1 return 0 用c 編寫加減乘除 include include using namespace std void main str1 10 str2 10...

如何用c 編寫連續加減乘除的計算器,函while語句

include include include include include include include using namespace std vector f string s else if s i else if s i s i else if s i s i else if s i ...