Ticker

6/recent/ticker-posts

Program to find greatest number in c (2 method of 3 variables)


First Method:

 #include<stdio.h>

void main(){

    int a,b,c;

    printf("Enter 3 numbers which you want to check: ");

    scanf("%d%d%d",&a,&b,&c);

    if(a>b && a>c){

        printf("%d is greater",a);

    }

    else if(b>c && b>a){

        printf("%d is greater",b);

        

    }

    else{

        printf("%d is greater",c);

    }

}



 Second method:

#include<stdio.h>
void main(){
    int a,b,c;
    printf("Enter 3 numbers which you want to check: ");
    scanf("%d%d%d",&a,&b,&c);

    if(a>b){
        if(a>c)
        printf("a is greater");
        
        else
        printf("c is greater");
    }
    
    else {
        if(b>c)
        printf(" b is greater");
        else
        printf("c is greater");
    }
    

}



Reactions

Post a Comment

0 Comments