User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 373,193 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,843 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser:
Views: 162 | Replies: 4
Reply
Join Date: May 2008
Posts: 11
Reputation: Beemer is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
Beemer Beemer is offline Offline
Newbie Poster

While Loops Help Please

  #1  
May 16th, 2008
Hi all I am learning C++ , but am still pretty new to it I have one problem I am writing a program to simply input a mark and then it gives the corresponding symbol and according to the symbol if its anything above an E it displays you pass and if not it displays you dont , I have had no problem writing this :
[ // Symbol issuing program as per mark out of 100.

#include <iostream>
using namespace std;

int symbol(int mark)
{
if (mark >= 0 && mark <= 39)
return 70;
if (mark >= 40 && mark <= 49)
return 69;
if (mark >= 50 && mark <= 59)
return 68;
if (mark >= 60 && mark <= 69)
return 67;
if (mark >= 70 && mark <= 79)
return 66;
if (mark >= 80 && mark <= 100)
return 65;
}

bool passOrNot (char symb)

{

char A, B, C, D, E , F;
if (symb <= 68 )
return 1;


}

int main()

{

int mark;
char symb;

cout << "Enter marks out of 100 followed by -10 to end inputs and display the results: ";
cin >> mark;
symb = symbol(mark);
cout << "Symbol corresponding to " << mark << " is " << symb;
if (passOrNot (symb))
cout << " You Pass Congratulations!"<< endl;
else
cout << " Unfortunately you fail" << endl;






return 0;
}
]

Except now I want to impliment a While loop into it so that I can enter a number of marks followed by -10 (or any defined number below 0) to end my inputs and display the results of each mark , yet everything I try doesnt work , it either gets stuck in a loop or simply stops on my 1st number entered , Please could somebody help me out here.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: May 2008
Posts: 11
Reputation: Beemer is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
Beemer Beemer is offline Offline
Newbie Poster

Re: While Loops Help Please

  #2  
May 16th, 2008
Basically I have this but entering -10 doesnt end it???

[// Symbol issuing program as per mark out of 100.

#include <iostream>
using namespace std;

int symbol(int mark)
{
if (mark >= 0 && mark <= 39)
return 70;
if (mark >= 40 && mark <= 49)
return 69;
if (mark >= 50 && mark <= 59)
return 68;
if (mark >= 60 && mark <= 69)
return 67;
if (mark >= 70 && mark <= 79)
return 66;
if (mark >= 80 && mark <= 100)
return 65;
}

bool passOrNot (char symb)

{

char A, B, C, D, E , F;
if (symb <= 68 )
return 1;


}

int main()

{


int mark;
char symb;
mark = 1;
while (mark != -10, mark++){
cout << "Enter mark out of 100 , enter -10 to end: ";
cin >> mark;
symb = symbol(mark);
cout << "Symbol corresponding to " << mark << " is " << symb;
if (passOrNot (symb))
cout << " You Pass Congratulations!"<< endl;
else
cout << " Unfortunately you fail" << endl;
}




return 0;
}
]
Reply With Quote  
Join Date: Oct 2006
Location: the Netherlands
Posts: 1,552
Reputation: niek_e is a jewel in the rough niek_e is a jewel in the rough niek_e is a jewel in the rough niek_e is a jewel in the rough 
Rep Power: 8
Solved Threads: 154
niek_e's Avatar
niek_e niek_e is offline Offline
Posting Virtuoso

Re: While Loops Help Please

  #3  
May 16th, 2008
You have an error here:
while (mark != -10, mark++)
Change it to: while (mark != -10)
And the program will end when -10 is entered

The next time you post code, please use code tags
Last edited by niek_e : May 16th, 2008 at 7:32 am.
"= != =="

PM's asking for help will be ignored..
Reply With Quote  
Join Date: May 2008
Posts: 11
Reputation: Beemer is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
Beemer Beemer is offline Offline
Newbie Poster

Re: While Loops Help Please

  #4  
May 16th, 2008
Thanks very much I cant believe i didnt realise that , works perfectly now .

I just joined today though and am wandering what you meant by PM's asking for help will be ignored?

Thanks
Reply With Quote  
Join Date: Oct 2006
Location: the Netherlands
Posts: 1,552
Reputation: niek_e is a jewel in the rough niek_e is a jewel in the rough niek_e is a jewel in the rough niek_e is a jewel in the rough 
Rep Power: 8
Solved Threads: 154
niek_e's Avatar
niek_e niek_e is offline Offline
Posting Virtuoso

Re: While Loops Help Please

  #5  
May 16th, 2008
You can send Private Messages (PM) to people by clicking on their name and select 'send Private Message'
But I got a lot of PM's of people begging me for source-code and it irritated the hell out of me.
So I added a signature PM's asking for help will be ignored.. so everyone can see that PMing me won't help them.
The signature will display in every message I post.

To add a signature of your own, goto 'control panel' (top of the screen) and click 'edit signature'
"= != =="

PM's asking for help will be ignored..
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb C++ Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the C++ Forum

All times are GMT -4. The time now is 10:01 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC