functions

hi all
our teacher gives us a homework and she says solve it in function ..I didnt know how to solve it

write a program that asks the user for her exam grade and prints a message indicating if the user has passed the exam or not

please I want someone to give me the code answer for this

MANY THANXX
please I want someone to give me the code answer for this


Why? It's your homework, you gain nothing if someone else writes it. This isn't a place to find people to do your homework. If you want help, try to solve it yourself and tell us where you're stuck at.
we wont do your homework, but we can help you with it. so post what you have so far and please use codetags "<>"
I try too hard but the black screen doesn't appear
I'm new in c++
and I did many homeworks by myself so I dont want anyone tell me what to do because I know my self,,
Last edited on
#include <iostream>
using namespace std;
int grade (int) ;

int main ()

{

for (intx=1;x<=60;x++)
cout<<"indicating"<<endl;

return 0;
}


int grade (int y)
{
return y*10;
}


this is my answer so tell me if there is any problem with it
Last edited on
- there is missing a space in your for loop between int and x
- the function grade doesnt get called

and it doesn't do anything of
write a program that asks the user for her exam grade and prints a message indicating if the user has passed the exam or not
, besides printing "indicating"
Last edited on
Wow, this is just all sorts of not on the right track. Can you explain what you have done so far? Because this just looks like nothing.
Excuse me?? if you want to help me then just do it, if you dont then do not reply, not this way. Got it?
I'll do your homework for you. I charge by the hour, I can give you my paypal information. Minimum of 15 USD down payment. $15/Hour, with minimum of $15 charge.
closed account (3qX21hU5)
Ok first problem

1) Your function int grade (int y) all this function does is multiplies whatever number you pass it by 10 return y*10. It does not do anything to determine if the student has a passing grade.

A) First determine what the passing grade limit is. Then you are going to have to check the number the user entered against the passing grade number to see if its higher then or less then.

2) You never called you function in int main().

A) To call a function you do something like this If I use your code as a example.

1
2
3
4
5
6
7
8
9
10
int main()
{
    int student; // Declares a variable to hold the students grade
    
    cin >> student; // User inputs thier grade into the variable
    
    grade(student); // Calls your function
    
    return 0;
}


3) You never asked the user for their grade! And you never created a variable to hold the grade!

A) Look up how input and output work (cin, and cout). http://www.cplusplus.com/doc/tutorial/basic_io/. And also if you don't know about variables by now I highly reccomend you pay attention more!!!!

4) I dont think you understand what a for loop does, and are using it incorrectly.

A) Check out here for more info on control structers. http://www.cplusplus.com/doc/tutorial/control/

4) The teacher said to print a message that tells the user if they have passed or not. The only cout you have is this
1
2
for (intx=1;x<=60;x++)
cout<<"indicating"<<endl;
and all that does is print "indicating" 60 times on the console. And not to mention you have no spaces between anything so it will error out.

A) Again check out how input and output work.

5) Your function is after main so even if you did call it in main it wouldn't work.

A) Put a function prototype above main, something like this
1
2
3
int grade(int y);

int main()
. If you need more info about function check here http://www.cplusplus.com/doc/tutorial/functions/

I think that covers most of it so their is your HELP! Also next time when people try to help you please act civilly. Also if they are teaching functions in your class already and this is what you can write only I would highly recommend you start over from the beginning.
Last edited on
if you want to help me then just do it


If you want help, behave civilly and make some sort of effort. Got it?
This is not a difficult problem to solve, but it looks like you are missing a lot of things you should have been taught before functions. The most obvious is that you do not have a cin statement at all. What you need to use for this problem are cout, cin, if, and basic function usage. It is not very clear as to why you have a loop or why you intended to return y*10.
Topic archived. No new replies allowed.