Current Set : Set 10
Set 1 Set 2 Set 3 Set 4 Set 5 Set 6 Set 7 Set 8 Set 9 Set 10
Question:3
Write a function in C language to take input for 2 numbers calculate and print their difference?
Sol:
#include <stdio.h>
//function definition
int diff()
{
int a,b;
printf("Enter 2 nos ");
scanf("%d %d",&a,&b);
if(a>b)
return(a-b);
else
return(b-a);
}
int main()
{
int d;
d=diff();
printf("difference = %d\n",d);
return 0;
}
Question:4
Write a function in C language to take input for 3 numbers check and print the largest number?
Sol:
#include <stdio.h>
//function definition
int largest()
{
int a,b,c;
printf("Enter 3 nos ");
scanf("%d %d %d",&a,&b,&c);
if(a>b && a>c)
return(a);
else
if(b>c)
return(b);
else
return(c);
}
int main()
{
int d;
d=largest();
printf("max no = %d\n",d);
return 0;
}




