The need:
This is program is just to find out largest of three numbers given by user and print their on the standard output using User defined function.
--------------------------------------------
#include<stdio.h>
int largest(int a,int b,int c); //declaration of function
int main()
{
int i,j,k,l;
printf("The program to give largest of 3 numbers.\n");
printf("Enter three integers\n");
scanf("%d %d %d",&i,&j,&k);
printf("Enter three integers\n");
scanf("%d %d %d",&i,&j,&k);
l=largest(i,j,k);
printf("The largest integer of the above given is %d\n\n",l);
return 0;
}
int largest(int a,int b,int c) //definition of function
{
int temp;
temp=(a>b)?a:b;
temp=(c>temp)?c:temp;
printf("The largest integer of the above given is %d\n\n",l);
return 0;
}
int largest(int a,int b,int c) //definition of function
{
int temp;
temp=(a>b)?a:b;
temp=(c>temp)?c:temp;
return temp;
}
}
--------------------------------------------
The approach:
First of all copy, paste, compile and run the program. After that try to understand the code and also try to compare with code of program10 of this blog.
The approach:
First of all copy, paste, compile and run the program. After that try to understand the code and also try to compare with code of program10 of this blog.
Remarks:
There are 2 noticeable points.
1. The output of both the programs is same.
2. The only difference is in the code (that is in this I have used UDF.)
No comments:
Post a Comment
feel free to ask your doubts... if any
you can post your doubts on
www.facebook.com/programsimply