while loop

I made up my own while loop to imitate cruse control on a car but theres just one error that keeps showing up
and no I'm not trying to get anybody to do my homework
here it is!!!

#include <iostream>
using namespace std;

int main()

{
int curent_speed;
int set_speed;

// this loop is to maintain speed on cruse control
cout<<"set cruise control to desired speed"<<endl;
cin>>set_speed;
cin>>curent_speed;
//this is the part where if the car where to incline or decline speed
//do to a hill up or down, the program helps stabilize speed
while (curent_speed < set_speed)
{
cout<<"automobile is now increasing to set speed"<<endl;
curent_speed++;
{
while (curent_speed > set_speed)
{
cout<<"automobile is now decreacing to set speed"<<endl;
curent_speed--;
{
if (curent_speed = set_speed)
cout<<"automobile is maintaining set speed"<<endl;

return 0;
}


// i'm thinking this if statement should go up top but i dont now
//the error Im getting is
//end of file found before left brace
Please use [code][/code] tags, good indentations will show the problem: you are opening 5 braces but closing only one
closed account (jLNv0pDG)
Also if (curent_speed = set_speed) should be if (curent_speed == set_speed)

thanks guys I changed it to this

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

while (current_speed < set_speed)
{
cout<<"speed is currently "<<current_speed<<endl;	
		current_speed++;
}

 while (current_speed > set_speed)
 {
cout<<"speed is currently "<<current_speed<<endl;	 
		current_speed--;
 }
	if (current_speed = set_speed)
		cout<<"cruse speed is maintaining at "<<set_speed<<endl;
	cout<<endl;
	cout<<endl;


the next question I have is where the hell on my keyboard is the key for an or statement
ex. while (a<100 or a>100) i onow its supposed to be 2 lines like II but thats two I's - what the hell do I do?
the next question I have is where the hell on my keyboard is the key for an or statement
ex. while (a<100 or a>100) i onow its supposed to be 2 lines like II but thats two I's - what the hell do I do?
what?
http://en.wikipedia.org/wiki/Pipe_%28character%29
This is the American keyboard:
http://upload.wikimedia.org/wikipedia/commons/3/3a/Qwerty.svg
The pipe is shift + \ ( the key before backspace )
( C++ also allows the keyword or )
The pipe is shift + \ ( the key before backspace )

It is on a UK QWERTY keyboard, but whenever I use an OS that doesn't have UK, and I have to use US layout, shift + \ never seems to work for me.

Anyway, what you're looking for is the pipe symbol, which looks like this: |
A logical or in C/C++ is done with ||, bitwise or uses a single pipe.

Edit: Oh, you guys have back-slash in a different place. We have + and = there.
Last edited on
thanks fellas || finally got it!!!
Topic archived. No new replies allowed.