hello all
can any body help me to correct this code please :cry: :cry:

i want it so it can print whats n is in these different cases.

this is my code and thanks alot for your help

#include <stdio.h>
#include <iostream.h>
#include <stdlib.h>



void main()
{
int ave, 1st, 1:2, 2:2, 3rd, pass, fail;



ave=85; //for example


if (ave>=70)
{
n=first;
}
else
if ((ave>=60)&&(ave<=69))
{
n=2:1;
}
else
if ((ave >=50)&&(ave<=59))
{
n=2:2;
}
else
if ((ave>=40)&&(ave<=49))
{
n=3rd;
}
else
if ((ave>=35)&&(ave<=40))
{
n=pass;
}
else if(ave<35)
{
n=fail;
}


cout<<n<<endl;
}

>#include <stdio.h>
>#include <iostream.h>
>#include <stdlib.h>
This are no longer valid C++. Use this instead:

#include <cstdio>
#include <iostream>
#include <cstdlib>

using namespace std;

>void main()
No! void main is not, and never has been, correct C++. main returns int:

int main()

>int ave, 1st, 1:2, 2:2, 3rd, pass, fail;
Okay, four of those seven identifiers are illegal. A valid identifier cannot begin with a digit and : isn't an option anywhere.

Before going any further, I'll recommend that you get a book on C++. If you already have one, I'll recommend that you actually read it.

Uh.... this looks like [bad] psuedo-code to me... which you probably copied, thus making it not yours (at least in terms of origin).

This question is so foolish and remedial, it'd do you (and the rest of humanity) some good to figure it out on your own methinks. I mean come on... void main()?

>#include <stdio.h>
>#include <iostream.h>
>#include <stdlib.h>
This are no longer valid C++. Use this instead:

#include <cstdio>
#include <iostream>
#include <cstdlib>

using namespace std;

Besides, is it even necessary to use stdio or stdlib here? Seems like a waste to me.

>Besides, is it even necessary to use stdio or stdlib here?
No, but it's a good chance to introduce the new C-style headers. Anyway, do you think explaining why they aren't needed would do any good at this point? ;)

thank for your replies
sorry im a very bad programmer
my program should be in c not c++

i think that ijust didnt know how to identfy 1st, 1:2, 2:2, 3rd, pass, fail

help please and thanks again

thank for your replies
sorry im a very bad programmer

That's quite obvious.

my program should be in c not c++

i think that ijust didnt know how to identfy 1st, 1:2, 2:2, 3rd, pass, fail

help please and thanks again

I suggest you pick up a copy of C Programming Language (2nd edition), by K&R. In the meantime, read this:

http://computer.howstuffworks.com/c.htm

thanks again

Im very new programmer

but i relly need this part of code working

if the code is totally wrong could you please tell me the working one if you know it.

thanks alot

by the way.....
i have borrowed 5 books from the library and i've had a look at them but i cannot understand anything!!!!!!!!! :rolleyes: :rolleyes:

i really need this code to work please help me with it if toy can :sad: :sad:

Hi there,
In my opinion, your code is beyond repair. You don't need help with your code, you need someone to teach you the basics of programming.
If you post what it is that you want your program to do, maybe we can help you.
Regards
arit

what is n?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.