Program in C and C++ to find the greatest number among three numbers Using function
C
CPP
#include<stdio.h> int Max(int a,int b,int c) { return (a>b&&a>c?a:b>c?b:c); } int main() { int x,y,z,m; printf("Enter three numbers:-"); scanf("%d%d%d",&x,&y,&z); m=Max(x,y,z); printf("Max = %d",m); return 0; }
#include<iostream> using namespace std; int Max(int a,int b,int c) { return (a>b&&a>c?a:b>c?b:c); } int main() { int x,y,z,m; cout<<"Enter three numbers:-"; cin>>x>>y>>z; m=Max(x,y,z); cout<<"Max = "<<m; return 0; }
Output:-
0 Comments