#include <iostream> // no .h
And please stop using `void main`. `int main` is one of the correct forms.
Printable View
#include <iostream> // no .h
And please stop using `void main`. `int main` is one of the correct forms.
Well, that's funny. You didn't add the closing brace after the loop like I said (I even gave you the line number).
Nor did you take the advice in post #8 about "main()" returning an int, not void.
Did not work, my friend began to despair:confused:
Indeed.
Code:Me: "The answer to question #4 is 'B'."
You: "How do I work this pencil?"
Excuse me I'm sorry because I am new to the language c:frown::frown::frown:
ok, post the updated code :)
That's fine, but we have not even gotten to any programming related advice. We're trying to start by making sure the code you posted has the correct syntax so you can compile it. I told you exactly what to type, in the exact location, and you didn't even get that far.
When you hit a roadblock like this, the best thing to do is take a step back. Go back to what you know, review what you've learned, and try going forward again slowly, making sure you understand each small step.
It's a bit suspicious that you claim you created* this code, but can't figure out that a brace is missing (especially when it was pointed out explicitly in this thread).
(*) I'll give you credit that you said "create" this code, and not "write" this code, because it is obviously a copy/paste mish-mosh of code written by others (i.e. here).
This is the last update and there is one error
unexpected end of file found
Code:#include<iostream.>
using namespace std;
int main()
{
float x,y,r;
const double p=3.14;
double area;
float a,b;
float d;
int choes;
do {
cout<<"[simple porogram]"<<endl;
cout<<" ==============="<<endl;
cout<<"main menu"<<endl;
cout<<"========="<<endl;
cout<<" Enter the number (1) to calculate area and vicinity of rectangle . "<<endl;
cout<<" Enter the number (2) to calculate area and vicinity of circle . "<<endl;
cout<<" Enter the number (3) to calculate area of triangle . "<<endl;
cout<<" Enter the number (4) to calculate vicinity of triangle . "<<endl;
cout<<" Enter the number (5) to calculate area and vicinity of square . "<<endl;
cout<<" Enter the number (6) to drow a rectangle ."<<endl;
cout<<" Enter the number (7) to drow a triangle ."<<endl;
cout<<" Enter the number (8) to drow diamond."<<endl;
cout<<" ===================================="<<endl;
cout<<" Enter the number :"<<endl;
cin>>choes;
switch (choes)
{
case 1:
cout<<"enter the length : ";
cin>>x;
cout<<"enter the width :";
cin>>y;
cout<<"the area of rectangle is :"<<x*y<<endl;
cout<<"the vicinity of rectangle is :"<<(x+y)*2<<endl;
break ;
case 2:
cout<<"enter the radius :"<<endl;
cin>>r;
area=(r*r)*p;
cout<<"the area of circle is :"<<area<<endl;
cout<<"the vicinity of circle is :"<<(r*p)*2<<endl;
break;
case 3:
cout<<"Enter the hight and base :"<<endl;
cin>>a>>b;
cout<<"the area of triangle is :"<<0.5*a*b<<endl;
break;
case 4:
cout<< "Enter lengths ribs :"<<endl;
cin>>a>>b>>d;
cout<< "the vicinity of triangle is :"<<a+b+d<<endl;
break;
case 5:
cout<<"Enter the length of the rib : "<<endl;
cin>>d,
cout<<"the area of square is :"<<d*d<<endl;
cout<<"the vicinity of square is :"<<d*4<<endl;
break;
case 6:
{
for(int z=1; z<=79; z++)
{
cout << "*";
}
cout << endl;
for(int i=1; i<=10; i++)
{
cout << "*";
for(int j=1; j<=77; j++)
{
cout << " ";
}
cout << "*" << endl;
}
for(int y=1; y<=79; y++)
{
cout << "*";
}
cout << endl;
}
break;
case 7:
{
for (int a = 1; a <= 20; a++)
{
for (int i = 1; i <= a; i++)
cout << "*";
cout << endl;
}
cout << endl;
}
break ;
case 8:
cout << " * \n * * *\n * * * *\n * * * * *\n * * * * * *\n* * * * * * *\n * * * * * *\n * * * * *\n * * * *\n * * *\n * \n";
break;
default :
cout<<" error "<<endl;
cout<<" (wrong choice) "<<endl;
while ( choes != 0 );
}
}
Write this
as thisCode:#include<iostream.>
and insert a right bracket } in line 106, like thisCode:#include<iostream>
But, Matticus is right.....Code:}while ( choes != 0 );
the same last error
Code:#include<iostream>
using namespace std;
int main()
{
float x,y,r;
const double p=3.14;
double area;
float a,b;
float d;
int choes ;
do {
cout<<"[simple porogram]"<<endl;
cout<<" ==============="<<endl;
cout<<"main menu"<<endl;
cout<<"========="<<endl;
cout<<" Enter the number (1) to calculate area and vicinity of rectangle . "<<endl;
cout<<" Enter the number (2) to calculate area and vicinity of circle . "<<endl;
cout<<" Enter the number (3) to calculate area of triangle . "<<endl;
cout<<" Enter the number (4) to calculate vicinity of triangle . "<<endl;
cout<<" Enter the number (5) to calculate area and vicinity of square . "<<endl;
cout<<" Enter the number (6) to drow a rectangle ."<<endl;
cout<<" Enter the number (7) to drow a triangle ."<<endl;
cout<<" Enter the number (8) to drow diamond."<<endl;
cout<<" ===================================="<<endl;
cout<<" Enter the number :"<<endl;
cin>>choes;
switch (choes)
{
case 1:
cout<<"enter the length : ";
cin>>x;
cout<<"enter the width :";
cin>>y;
cout<<"the area of rectangle is :"<<x*y<<endl;
cout<<"the vicinity of rectangle is :"<<(x+y)*2<<endl;
break ;
case 2:
cout<<"enter the radius :"<<endl;
cin>>r;
area=(r*r)*p;
cout<<"the area of circle is :"<<area<<endl;
cout<<"the vicinity of circle is :"<<(r*p)*2<<endl;
break;
case 3:
cout<<"Enter the hight and base :"<<endl;
cin>>a>>b;
cout<<"the area of triangle is :"<<0.5*a*b<<endl;
break;
case 4:
cout<< "Enter lengths ribs :"<<endl;
cin>>a>>b>>d;
cout<< "the vicinity of triangle is :"<<a+b+d<<endl;
break;
case 5:
cout<<"Enter the length of the rib : "<<endl;
cin>>d,
cout<<"the area of square is :"<<d*d<<endl;
cout<<"the vicinity of square is :"<<d*4<<endl;
break;
case 6:
{
for(int z=1; z<=79; z++)
{
cout << "*";
}
cout << endl;
for(int i=1; i<=10; i++)
{
cout << "*";
for(int j=1; j<=77; j++)
{
cout << " ";
}
cout << "*" << endl;
}
for(int y=1; y<=79; y++)
{
cout << "*";
}
cout << endl;
}
break;
case 7:
{
for (int a = 1; a <= 20; a++)
{
for (int i = 1; i <= a; i++)
cout << "*";
cout << endl;
}
cout << endl;
}
break ;
case 8:
cout << " * \n * * *\n * * * *\n * * * * *\n * * * * * *\n* * * * * * *\n * * * * * *\n * * * * *\n * * * *\n * * *\n * \n";
break;
default :
cout<<" error "<<endl;
cout<<" (wrong choice) "<<endl;
} while ( choes != 0 );
}
Now you're starting to look like a troll.
Count the opening braces in your code ( { ).
Count the closing braces in your code ( } ).
Tell us how many of each you have.
As I said about the switch cases in a previous post, do the following :
1 - Remove the brackets from case 6 (line 64 and 86)
2 - Remove the brackets from case 7 (line 89 and 97)
Done that gave me 12 error
I will try later
Thank you
good night
D:\c++\rrrrrrrrrrr.cpp(88) : error C2360: initialization of 'y' is skipped by 'case' label
D:\c++\rrrrrrrrrrr.cpp(81) : see declaration of 'y'
D:\c++\rrrrrrrrrrr.cpp(88) : error C2360: initialization of 'i' is skipped by 'case' label
D:\c++\rrrrrrrrrrr.cpp(71) : see declaration of 'i'
D:\c++\rrrrrrrrrrr.cpp(88) : error C2360: initialization of 'z' is skipped by 'case' label
D:\c++\rrrrrrrrrrr.cpp(65) : see declaration of 'z'
D:\c++\rrrrrrrrrrr.cpp(99) : error C2360: initialization of 'a' is skipped by 'case' label
D:\c++\rrrrrrrrrrr.cpp(90) : see declaration of 'a'
D:\c++\rrrrrrrrrrr.cpp(99) : error C2360: initialization of 'y' is skipped by 'case' label
D:\c++\rrrrrrrrrrr.cpp(81) : see declaration of 'y'
D:\c++\rrrrrrrrrrr.cpp(99) : error C2360: initialization of 'i' is skipped by 'case' label
D:\c++\rrrrrrrrrrr.cpp(71) : see declaration of 'i'
D:\c++\rrrrrrrrrrr.cpp(99) : error C2360: initialization of 'z' is skipped by 'case' label
D:\c++\rrrrrrrrrrr.cpp(65) : see declaration of 'z'
D:\c++\rrrrrrrrrrr.cpp(102) : error C2361: initialization of 'a' is skipped by 'default' label
D:\c++\rrrrrrrrrrr.cpp(90) : see declaration of 'a'
D:\c++\rrrrrrrrrrr.cpp(102) : error C2361: initialization of 'y' is skipped by 'default' label
D:\c++\rrrrrrrrrrr.cpp(81) : see declaration of 'y'
D:\c++\rrrrrrrrrrr.cpp(102) : error C2361: initialization of 'i' is skipped by 'default' label
D:\c++\rrrrrrrrrrr.cpp(71) : see declaration of 'i'
D:\c++\rrrrrrrrrrr.cpp(102) : error C2361: initialization of 'z' is skipped by 'default' label
D:\c++\rrrrrrrrrrr.cpp(65) : see declaration of 'z'
D:\c++\rrrrrrrrrrr.cpp(109) : fatal error C1004: unexpected end of file found
Error executing cl.exe.
rrrrrrrrrrr.exe - 12 error(s), 0 warning(s)
Code:#include<iostream>
using namespace std;
int main()
{
float x,y,r;
const double p=3.14;
double area;
float a,b;
float d;
int choes ;
do {
cout<<"[simple porogram]"<<endl;
cout<<" ==============="<<endl;
cout<<"main menu"<<endl;
cout<<"========="<<endl;
cout<<" Enter the number (1) to calculate area and vicinity of rectangle . "<<endl;
cout<<" Enter the number (2) to calculate area and vicinity of circle . "<<endl;
cout<<" Enter the number (3) to calculate area of triangle . "<<endl;
cout<<" Enter the number (4) to calculate vicinity of triangle . "<<endl;
cout<<" Enter the number (5) to calculate area and vicinity of square . "<<endl;
cout<<" Enter the number (6) to drow a rectangle ."<<endl;
cout<<" Enter the number (7) to drow a triangle ."<<endl;
cout<<" Enter the number (8) to drow diamond."<<endl;
cout<<" ===================================="<<endl;
cout<<" Enter the number :"<<endl;
cin>>choes;
switch (choes)
{
case 1:
cout<<"enter the length : ";
cin>>x;
cout<<"enter the width :";
cin>>y;
cout<<"the area of rectangle is :"<<x*y<<endl;
cout<<"the vicinity of rectangle is :"<<(x+y)*2<<endl;
break ;
case 2:
cout<<"enter the radius :"<<endl;
cin>>r;
area=(r*r)*p;
cout<<"the area of circle is :"<<area<<endl;
cout<<"the vicinity of circle is :"<<(r*p)*2<<endl;
break;
case 3:
cout<<"Enter the hight and base :"<<endl;
cin>>a>>b;
cout<<"the area of triangle is :"<<0.5*a*b<<endl;
break;
case 4:
cout<< "Enter lengths ribs :"<<endl;
cin>>a>>b>>d;
cout<< "the vicinity of triangle is :"<<a+b+d<<endl;
break;
case 5:
cout<<"Enter the length of the rib : "<<endl;
cin>>d,
cout<<"the area of square is :"<<d*d<<endl;
cout<<"the vicinity of square is :"<<d*4<<endl;
break;
case 6:
for(int z=1; z<=79; z++)
{
cout << "*";
}
cout << endl;
for(int i=1; i<=10; i++)
{
cout << "*";
for(int j=1; j<=77; j++)
{
cout << " ";
}
cout << "*" << endl;
}
for(int y=1; y<=79; y++)
{
cout << "*";
}
cout << endl;
break;
case 7:
for (int a = 1; a <= 20; a++)
{
for (int i = 1; i <= a; i++)
cout << "*";
cout << endl;
}
cout << endl;
break ;
case 8:
cout << " * \n * * *\n * * * *\n * * * * *\n * * * * * *\n* * * * * * *\n * * * * * *\n * * * * *\n * * * *\n * * *\n * \n";
break;
default :
cout<<" error "<<endl;
cout<<" (wrong choice) "<<endl;
} while ( choes != 0 );
}
Those last few bracekts you were told to remove need to be put back because you are using an old compiler that does not respect the new standard on for-loop variable scoping.
You are using various wrong wrong words and bad spelling in there. Rather than "vicinity", you actually mean "perimeter". And instead of "ribs" you mean "sides". "height" is spelt with an 'e', and "draw" is spelt with an 'a'.
Your terrible approximation of Pi will give you a bad result too.
There is still one missing curly bracket. Figure out what each bracket matches with and you should be able to see the problem.