#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

Salem commented: 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!!!!!!!!!!!!! -7

Recommended Answers

All 8 Replies

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.

you are expecting function max to return maximum value but its return type is void.

#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);
}

commented: Learn to use code tags! -4

the function, max, needs to be an int.

do not put 'int' in the arguments when you call the function.

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.

commented: I only REPlied ;) +36
#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.

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.