Friday, March 28, 2014

Get three numbers from user , print sum, product , average using single if statements and if all three numbers are equal , print all numbers are equal if they are not equal then print the largest number entered by the user

#include<stdio.h>
#include<stdlib.h>
void line()
{
int i,j;
printf("\n");
for(i=1;i<=42;i++)
printf("=");
}
void header()
{
printf("\n");
printf("Built and Designed by Arslan Malik\n\n www.CworldbyAS.blogspot.com");
printf("\n");
}
int main()
{
line();
header();
line();

int a,b,c,sum,average,product;
printf("\nEnter Three Integers : \n");
scanf("%d%d%d",&a,&b,&c);
sum=a+b+c;
printf("\nSum is : %d \n",sum);
average=(a+b+c)/3;
printf("Average is : %d \n",average);
product=a*b*c;
printf("Product is  : %d\n",product);

    if (a==b==c)
        printf("All integers are euqal.\n");
    if(a>b && a>c)
        printf("Largest integer is : %d \n",a);
    if(b>a && b>c)
        printf("Largest Number is : %d \n",b);
    if(c>a && c>b)
        printf("Largest number is : %d \n",c);
    if(a<b && a<c)
        printf("Smallest number is : %d \n",a);
    if(b<a && b< c)
        printf("Smallest number is : %d \n",b);
    if(c<a && c<b)
        printf("Smallest number is : %d \n",c);

return 0;
}

No comments:

Post a Comment