Q. Write a program input three numbers then find out the biggest one in "C" Language.(using 3rd variable)
#include<stdio.h>
int main()
{
int a,b,c,big=0;
printf("enter three numbers");
scanf("%d%d%d",&a,&b,&c);
big=0;
if(a>big)
big=a;
if(b>big)
big=b;
if(c>big)
big=c;
printf("%d is the biggest value",big);
}
Q. Write a program input three numbers then find out the biggest one in "C" Language.(using logical and operator)
#include<stdio.h>
int main()
{
int a,b,c,big=0;
printf("enter three numbers");
scanf("%d%d%d",&a,&b,&c);
if (a>b&&a>c)
printf("a is big");
if(b>a&&b>c)
printf("b is big");
if(c>a&&c>b)
printf("c is big");
}
Q. Write a program input three numbers then find out the biggest one in "C" Language.(using nested if...else)
#include<stdio.h>
int main()
{
int a,b,c;
printf("enter three numbers");
scanf("%d%d%d",&a,&b,&c);
if (a>b)
if(a>c)
printf("a is big");
else
printf("c is big");
else
if(b>c)
printf("b is big");
else
printf("c is big");
}
No comments:
Post a Comment