Mobile Brand ID:6636


A boy wants to buy a new mobile. He has chosen three mobile phones of different brands and are kept in the following order (SonySamsungNokia). Now he has to choose the most preferred mobile. The RAM (in MB) and the cost of each mobile are given as the input. The program must print the brand name of the most preferred mobile.
Note: 
    - The mobile with the lowest cost is the preferred mobile.
    - If two or more mobiles have the same cost, then the mobile with maximum RAM is the preferred mobile.

Input Format:
Three lines with each line containing the RAM and the cost of the mobile separated by a space.

Output Format:
The first line contains the brand name of the mobile.

Example Input/Output 1:
Input:
1024 4500   
2048 4500  
1536 6000   

Output:
Samsung

Example Input/Output 2:
Input:
512 1000  
1024 1000  
2048 1000  

Output:

Nokia

Program in c:

#include<stdio.h>

#include<stdlib.h>


int main()

{int a,b,c,d,e,f;

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

if(a==b && b==c)

{

    if(d>=e && d>=f)

    printf("Sony");

    else if(e>=f && e>=d)

    printf("Samsung");

    else if(f>=d && f>=e)

    printf("Nokia");

}

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

{

    if(d>=e)

    printf("Sony");

    else

    printf("Samsung");

}

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

{

    if(e>=f)

    printf("Samsung");

    else

    printf("Nokia");

}

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

{

    if(f>d)

    printf("Nokia");

    else

    printf("Sony");

}

else if(a<b &&a<c)

{

   printf("Sony");

}

else if(b<c && b<a)

printf("Samsung");

else if(c<a && c<b)

printf("Nokia");

}

Comments

Popular Posts