Sunday, September 29, 2013

Find largest value among three numbers using conditional statement

Find largest value among three numbers using conditional statement
Find largest value among three numbers using conditional statement  in C

#include<stdio.h>
main()
{
    int a,b,c;
    printf("Enthe the value of a:\n");
    scanf("%d",&a);
    printf("Enter the value of b:\n");
    scanf("%d",&b);
    printf("Enter the value of c:\n");
    scanf("%d",&c);
    if((a>b)&&(a>c))
        printf("a is largest\n");
    else if
        (b>c)
        printf("b is largest\n");
    else
        printf("c is largest\n");
}

Largest value among 3 (three) numbers

Find the largest value among three numbers
Find the largest value among three numbers in C


#include<stdio.h>
main()
{
    int a,b,c,big;
    printf("Enthe the 1st number: ");
    scanf("%d",&a);
    printf("Enthe the 2nd number: ");
    scanf("%d",&b);
    printf("Enthe the 3rd number: ");
    scanf("%d",&c);
    big=(a>b&&a>c?a:b>c?b:c);
    {
    printf("The biggest number is: %d",big);
    }
}

Largest value between two variable

Find the largest value between two variable
Find the largest value between two variable in C

#include<stdio.h>
main()
{
    int a,b;
    printf("Enthe the value of a\n");
    scanf("%d",&a);
    printf("Enter the value of b\n");
    scanf("%d",&b);
    if(a>b)
        printf("a is largest\n");
    else
        printf("b is largest\n");
}