#inclxude<conio.h>
#include<stdio.h>
#include<stdlib.h>
max(int a,int b,int c);
void main (void)
{

clrscr();
int a,b,c,max;
long z;
printf("input three numbers by giving space");
scanf("%d %d %d",&a,&b,&c);
z=max(a,b,c);
printf("Max value is %lb",z);
getch();
}
void max(int a ,int b,int c )
{
 if(a>b&&a>c)
 return(a);
if(b>c&&b>a)
return(b);
return(c);
}

i make that program to find the maximum value. please help

Edited 7 Years Ago by John A: added code tags

Comments
If you're going to demand people fix your mess, at least have the courtesy to read the rules and figure out the GODDAM CODE TAGS!!!!!!!!!!!!!

void max(...

has no return type (it's void) but you're trying to return integers. and yet, you have the function attempting to assign a value to a long integer. why long? change it to int, and change the return type of max to int.

#include<conio.h>
#include<stdio.h>
#include<stdlib.h>
max(int a,int b,int c);
void main ()
{

clrscr();
int a,b,c,max;
long z;
printf("input three numbers by giving space");
scanf("%d %d %d",&a,&b,&c);
max=max(int a, b, c);there it is giving expression syntax
printf("Max value is %d",max);
getch();
}
max(int a ,int b,int c )
{
if(a<b&&a<c)
return(a);
if(b<c&&b<a)
return(b);
return(c);
}

Comments
Learn to use code tags!

Besides all the other "evils" in your code that others have pointed out already, the logic of your max() function in your last post is incorrect. It appears to be returning the minimum value out of the three values passed in to the function.

You should consider yourself lucky that you're even getting people responding to your thread - you have made 10 posts and you still haven't figured out how to use code tags - although that is probably the least of your problems going by the poor quality of your code. You obviously need to study the core basics of C in more detail. And if you have, then you need to study harder.

Comments
I only REPlied ;)
#inclxude<conio.h>
// shoulld be #include<conio.h>

#include<stdio.h>
#include<stdlib.h>
max(int a,int b,int c);
void main (void)
{

clrscr();
int a,b,c,max;
long z;
printf("input three numbers by giving space");
// avoid spaces between arguments of scanf
scanf("%d %d %d",&a,&b,&c);
z=max(a,b,c);
printf("Max value is %lb",z);
getch();
}
// when you are returning values from function need to specify the //return type
// here the return type should be int as you are returning integer //value.

// int max(int a ,int b,int c )
 
void max(int a ,int b,int c )
{
 if(a>b&&a>c)
 return(a);
if(b>c&&b>a)
return(b);
return(c);
}

i make that program to find the maximum value. please help

you just need to make the above changes.

you just need to make the above changes.

Does that include the use of void main() as well? I sincerely hope not.

This article has been dead for over six months. Start a new discussion instead.