write a function to calculate the maximum number of four numbers
notice that the four numbers will be entered by the user

We won't simply do your homework for you.

Show us how far you've got. Ask a question about something in your code you don't understand. You're going to have to do more than simply put the question up and hope we do it for you.

#include<iostream>
#include<math.h>
using namespace std ;
int a,b,c,d,num;
int maximum()
{
    num=0;
    if(a>b && a>c && a>d)       { num==a;}
    else if(b>a && b>c && b>d)  { num==b;}
    else if(c>a && c>b && c>d)  { num==c;}
    else                        { num==d;}
    return num;
}
int main()
{
    a=5 , b=7 , c=2 , d=3;
maximum();
cout<<"maximum number="<<num;
}

I tried that code but when I run it the max number appears to be zero

Well, you set n to zero on line 7 (n = 0;) and then you never change it so it's obviously still zero. Remember that == checks for equality. It does not set num to equal anything. Therefore, num==a; should be num = a; and then continue the same pattern on lines 9-11.

num==a;
This means "is the value of num the same as the value of a?" It does not change the value of num.

Perhaps you're trying to set the value of num? Did you mean num=a; ?

I found my mistake .. thank you all

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.