+ 1

Why does this output an error?

Code: #include <cassert> #include <cctype> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <limits> #include <string> #include <iostream> #include <sstream> #include <functional> #include <algorithm> #include <bitset> #include <deque> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <vector> #include <system_error> #include <string> using namespace std; int add(int c1, int c2) int sos = c1+c2 return sos; int main(){ for(a1=5 a1<=67 a+=7) cout<<"___________________\n=============" string scan = "dfig.res.error" int n1 = 16; float n2 = 54.541; cout<<"Please enter two numbers and a symbol\n"; int a; int b; int c; int d; int e; int f; int x; int y; int z; int w; int r; char sym; //operator char is = '=' cin>>a; cin>>sym; cin>>b; cin>>sym; cin>>c; cin>>sym; cin>>d; cin>>sym; cin>>e; cin>>sym; cin>>f; cin>>sym; cin>>x; cin>>sym; cin>>y; cin>>sym; cin>>z; cin>>sym; cin>>w; cin>>sym; cin>>r; switch(1){ case '+': cout<<a<<'+'<<b<<'+'<<c<<'+'<<d<<'+'<<e<<'+'<<f<<'+'<<x<<'+'<<y<<'+'<<z<<'+'<<w<<'+'<<r<<'='==a+b+c+d+e+f+x+y+z+w+r; break; case '-': cout<<a-b-c-d-e-f-x-y-z-w-r; break; case '*': cout<<a*b*c*d*e*f*x*y*z*w*r; break; case '/': cout<<a/b/c/d/e/f/x/y/z/w/r; if(a||b||c||d||e||f||x||y||z||w||r==0){ cout<<"UNDEFINED,CANNOT DIVIDE BY 0!"; case '1': if(a+b){ if(1+1){ cout<<"1+1=2"; } if(1+2==2+1){ cout<<'1+2=3'; } if(1+3==3+1){ cout<<'1+3=4'; } if(1+4==4+1){ cout<<'1+4=5'; } if(1+5==5+1){ cout<<'1+5=6' } if(1+6==6+1){ cout<<'1+6=7' } } }break; } return 0; } Error: Compilation error

6th May 2017, 9:45 AM
mei
mei - avatar
10 Respuestas
+ 4
@mei he is not rude, he's just telling you what's wrong with the code and it can help you to compile this somewhere else than code playground
6th May 2017, 10:22 AM
‎ɐısıօլɐ
‎ɐısıօլɐ - avatar
+ 1
how could the switch(1) be wrong? I SAID WHAT DO YOU MEAN!!!!!!!!??????????
6th May 2017, 10:14 AM
mei
mei - avatar
+ 1
AND WHAT NUMBER DO YOU CHOOSE!!!??? 1....10
6th May 2017, 10:18 AM
mei
mei - avatar
0
There are various errors: the body of your method add has to be between { and } the syntax of the for loop os wrong: for (type name=value;condition;statement){} would be right so in your case for (int a1=5;a1 <=67;a1+=7) cout<<"your text"; you also have to end every statement with ; (semicolon ) e.g string scan="dfig.res.error"; the switch (1) makes no sense at all. then the if with the 0 check is wrong: if (a==0||b==0 ...) would be right. If the aim of your code is to make a nice calculator, google stroustroup (the creator of c++) calculator.
6th May 2017, 9:58 AM
No One
No One - avatar
0
This makes sense: There are various errors: the body of your method add has to be between { and } the syntax of the for loop os wrong: for (type name=value;condition;statement){} would be right so in your case for (int a1=5;a1 <=67;a1+=7) cout<<"your text"; you also have to end every statement with ; (semicolon ) e.g string scan="dfig.res.error" This makes no sense: the switch (1) makes no sense at all. then the if with the 0 check is wrong: if (a==0||b==0 ...) would be right.
6th May 2017, 10:13 AM
mei
mei - avatar
0
如此无礼! 你选择了什么? 1 .... 10 开关(1)如何出错? 我说你是什么意思? 这说得通: 有各种错误:您添加文本的方法必须在{和}之间 for循环错误的语法: For(type name = value; condition; statement){} 在你的情况下会是对的 For(int a1 = 5; a1 <= 67; a1 + = 7) Cout <<“你的话” 你也必须结束每一个陈述; (分号) 例如 String scan =“dfig.res.error” 这个不成立 开关(1)完全没有意义。 那么如果检查与0是错误的: 如果(a == 0 || b == 0 ...) 会是对的 Rúcǐ wú lǐ! Nǐ xuǎnzéle shénme? 1.... 10 Kāiguān (1) rúhé chūcuò? Wǒ shuō nǐ shì shénme yìsi? Zhè shuō dé tōng: Yǒu gè zhǒng cuòwù: Nín tiānjiā wénběn de fāngfǎ bìxū zài {hé} zhī jiān for xúnhuán cuòwù de yǔfǎ: For(type name = value; condition; statement){} zài nǐ de qíngkuàng xià huì shì duì de For(int a1 = 5; a1 <= 67; a1 + = 7) Cout <<“nǐ dehuà” nǐ yě bìxū jiéshù měi yīgè chénshù; (fēn hào) lìrú String scan =“dfig.Res.Error” zhège bùchénglì kāiguān (1) wánquán méiyǒu yìyì. Nàme rúguǒ jiǎnchá yǔ 0 shì cuòwù de: Rúguǒ (a == 0 || b == 0...) Huì shì duì de
6th May 2017, 10:21 AM
mei
mei - avatar
0
Then read this!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 如此无礼! 你选择了什么? 1 .... 10 开关(1)如何出错? 我说你是什么意思? 这说得通: 有各种错误:您添加文本的方法必须在{和}之间 for循环错误的语法: For(type name = value; condition; statement){} 在你的情况下会是对的 For(int a1 = 5; a1 <= 67; a1 + = 7) Cout <<“你的话” 你也必须结束每一个陈述; (分号) 例如 String scan =“dfig.res.error” 这个不成立 开关(1)完全没有意义。 那么如果检查与0是错误的: 如果(a == 0 || b == 0 ...) 会是对的 Rúcǐ wú lǐ! Nǐ xuǎnzéle shénme? 1.... 10 Kāiguān (1) rúhé chūcuò? Wǒ shuō nǐ shì shénme yìsi? Zhè shuō dé tōng: Yǒu gè zhǒng cuòwù: Nín tiānjiā wénběn de fāngfǎ bìxū zài {hé} zhī jiān for xúnhuán cuòwù de yǔfǎ: For(type name = value; condition; statement){} zài nǐ de qíngkuàng xià huì shì duì de For(int a1 = 5; a1 <= 67; a1 + = 7) Cout <<“nǐ dehuà” nǐ yě bìxū jiéshù měi yīgè chénshù; (fēn hào) lìrú String scan =“dfig.Res.Error” zhège bùchénglì kāiguān (1) wánquán méiyǒu yìyì. Nàme rúguǒ jiǎnchá yǔ 0 shì cuòwù de: Rúguǒ (a == 0 || b == 0...) Huì shì duì de
7th May 2017, 12:20 AM
mei
mei - avatar
0
Also, you misspelled 'is' as 'os'.
6th Jul 2017, 2:07 AM
mei
mei - avatar
- 1
And so rude!?
6th May 2017, 10:20 AM
mei
mei - avatar
- 1
Insulted me...¥:848(,!&9,3¥,83),¥29.)83;¥39:¥3&,0’zwpxkpnigug,’epenpxjwhsiqhxosxgwjdpjp,+{‘,!03!”,!92;¥2)1 the hdeidjowdjoejcojd2’donehfuwb,29
2nd Apr 2018, 6:30 AM
mei
mei - avatar