Coding Practice

We have RUNU and JHUNU with us from a distant village of Bangladesh...

Write a full C program for each of the following problems

We have RUNU and JHUNU with us from a distant village of Bangladesh who came to this Dhaka city for the first time. They have a special bag of money which gives them money every morning when they wake up from sleep. Somehow they figure out how much money each day they will be able to get from the magic bag in the next N days.

So, now they want your help to decide where to eat in this Dhaka city. Well for your help they also provided the list below:

  • Roadside Food if the amount is 100 or less
  • Fast Food if the amount is 250 or above but less than 350
  • Kacchi if the amount is 350 or above
  • Otherwise in BFC

Input: An integer N (No. of days). Followed by an integer in the next N line defining the amount of each of the N days.

Output: "Roadside Food", "Fast Food", "Kacchi" or "BFC" depending on the amount of each day. Table:

Sample Input:    Sample Output:

3

999                        Kacchi

9                            Roadside Food

282                        Fast Food

Sample Output
3
999
9
282
Kacchi
Roadside Food
Fast Food
 
Process returned 0 (0x0)   execution time : 19.498 s
Press any key to continue.
Source Code
#include<stdio.h>
#define MAX 100

int main()
{
    int i, NDays, amount[MAX];

    scanf("%d", &NDays);

    for(i = 0; i < NDays; i++)
    {
        scanf("%d", &amount[i]);
    }
    for(i = 0; i < NDays; i++)
    {
        if(amount[i] <= 100)
        {
            printf("Roadside Food\n");
        }
        else if(amount[i] >= 250 && amount[i] <= 350)
        {
            printf("Fast Food\n");
        }
        else if(amount[i] >= 350)
        {
            printf("Kacchi\n");
        }
        else
            {
                printf("BFC\n");
            }
    }
}
Sample Output
3
999
9
282
Kacchi
Roadside Food
Fast Food
 
Process returned 0 (0x0)   execution time : 19.498 s
Press any key to continue.

No comments:

Post a Comment

Change Theme
X