I would suggest if you get an error message, post it. It will make diagnosing your problems a lot easier.
Adrian
my programme is about calculating percentages .of total 5 subjects in if statement.at the end of programme i wrote getch();return( 0);.at the closing of statements there is a warning like function should return a value. what should i include so that my programme will be executed.
my programme is about calculating percentages .of total 5 subjects in if statement.at the end of programme i wrote getch();return( 0);.at the closing of statements there is a warning like function should return a value. what should i include so that my programme will be executed.
The code you posted is pretty sloppy. I’m surprised that a compiler would accept it. Things wrong:
main() returns an int. You should specify this even if the C standard says you don’t need to.
Your indenting was unreadable.
You mistyped an end parenthesis with a 0. This could not be the code you were using.
if bodies and else bodies should have braces ({}) around them, otherwise you are just wishing for a problem to happen.
per is not initialised before use
getch() is not part of stdio.h, use scanf(“%*[^\n]”) to wait for a enter key to be pressed instead.
Not all execution paths return a value
You didn’t add anything (that was your original question, right?).
So what do you want to do from here?
Adrian
so what u told me i have done inspite of this iam getting an error msg like
function should return a value.
iam using cpp compiler so i hve changed my file name to .c and iam doing this.
programme but iam getting this problem.
can u please post the programme for me. the programme is about calculating per in 5 sub
and using if statement with the respective division calculating per and displayin the statement.
so what u told me i have done inspite of this iam getting an error msg like
function should return a value.
iam using cpp compiler so i hve changed my file name to .c and iam doing this.
programme but iam getting this problem.
can u please post the programme for me. the programme is about calculating per in 5 sub
and using if statement with the respective division calculating per and displayin the statement.
thans for ur reply
hey dude the first thingy u got to do is use
printf ("enter the value of a \n");
and not
printf ("enter the value of a \n",a);
next give main declaration as
void main(void)
and then remove ur return statement.
the correct code is
void main ( )
{
int a, b, c;
printf("enter a number a \n");
scanf("%d",&a);
printf("enter a number b \n");
scanf("%d",&b);
printf("enter a number c \n");
scanf("%d",&c);
}
Comment