Need help with this c++ program!!

I should write another value-returning function, namely passOrNot of return type bool. It receives a symbol in a parameter of type char. If the symbol is either E or F, the value false should be returned (because the person did not pass), otherwise the value true should be returned (because the person passes). Below the main function is given. As you will see i have allready done the function symbol but dont know how to do the function passOrNot of return type bool. Pls help if you can.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Value returning Function with one Value Parameter
#include <iostream>
using namespace std;

// the required function 'symbol' and 'passOrNot' is inserted here
char symbol(int mark)
{         // Function symbol starts
    char returnVal = 'F';
    if(mark >= 40)
    {
        returnVal = 'E';
        if(mark >= 50)
        {
            returnVal = 'D';
            if(mark >= 60)
            {
                returnVal = 'C';
                if(mark >= 70)
                {
                    returnVal = 'B';
                    if(mark >= 80)
                    {
                        returnVal = 'A';
                    }
                }
            }
        }
    }
    return returnVal;
}                       // End of function 'symbol'



int main ( )
{
    int  mark;
    char symb;
   
    cout << "Enter mark out of 100: ";
    cin >> mark;
    symb = symbol (mark);
    cout << "Symbol corresponding to " << mark << " is " << symb << endl;
    if (passOrNot (symb))
        cout << ". You pass - congratulations!" << endl;
    else
        cout << ". Unfortunately you fail." << endl;
        
    return 0;
}
Last edited on
it's the same as the "int" return type you had.

1
2
3
4
5
6
7
bool passOrNot(char grade)
{
     if (grade == 'E' || grade == 'F')
          return false;
     else
          return true;
}


to receive this value, in your main function, you need the statement

 
bool pass = passOrNot(symb);

Last edited on
thanks for the help akimatsu!!! really appreciated.
Last edited on
One of my Colleagues is doing the same course through UNISA and I have just looked through his notes. If you had attempted and understood the previous assignments then you would have had sufficient knowledge to at least attempted a solution on your own.

As a professional (self taught) programmer with almost 30 years experience, I am horrified at the number of "certified programmers" who cannot write any code without forums such as this, which I must add, perform a valuable service to the industry but are being abused by those that are too lazy to do their own homework.
Last edited on
That is the prime reason, the IT industry say that they dont find talent and find a reason to go outsourced :)



No, the reason IT goes outsourced (in the majority of cases) is that senior managment with little or no understanding of IT projects get fooled into beliving outsourcing is both a cheep option and a good option - in reality it can be one or the other, but is very rarely both!
However, I would certainly agree with GAAB that there are a lot of very poor programmers out there - again managment is partly to blame there, as putting 'mentoring / training junior staff' down on your timesheet will often lead to 'Why did you waste so much time on this...' questions.

Agreed though.

It is a CHEAP option not necessarily better.
Though there are some benefits of globalization, ignoring the talent at home would be disastrous for the young future.
Looking at the admission count at uni's, the numbers shows that many are turning towards other non-IT sectors as IT is found to be not a well-paid or worth-the-effort any more.


We need more good software aware people in management. Unfortunately, the competent software engineers don't want to go anywhere near management positions, wanting to stick to what they enjoy. That leaves the ones who talk the talk but can't walk the walk to move up the promotion ladder. So continuing with that warped logic, it's our own fault the managers are clueless!
Topic archived. No new replies allowed.