Course Content
Week 6 Assignment Answers
0/3
Week 7 Assignment Answers
0/2
Week 8 Assignment Answers
0/2
Week 1 Assignment Answers
0/3
Week 2 Assignment Answers
0/3
Week 3 Assignment Answers
0/3
Week 4 Assignment Answers
0/3
Week 5 Assignment Answers
0/3
[Week 1-8] NPTEL Introduction to programming in C Assignment Answers 2024
About Lesson

You have a certain number of 100 rupee notes, 10 rupee notes and 1 rupee notes with you.

There is an item you want to buy whose price is given to you.

Write a program to find if the item is affordable, that is the price of the item is less than or equal to the current money you have.

Input

—–

Four non negative integers. 

The first input is an integer representing the number of 100 rupee notes.

The second input is an integer representing the number of 10 rupee notes.

The third input is an integer representing the number of 1 rupee notes.

The fourth input is an integer representing the price of the item.

Output

——

You have to output 1 if the item is affordable.

You have to output 0 if the item is not affordable. 

Sample Test Cases

InputOutput
Test Case 17 7 0 7701
Test Case 20 0 0 01
Test Case 319 12 10 20301
Test Case 41 1 1 10000
Test Case 55 333 1 38320
Test Case 65 1 2 1201
Test Case 73 17 9 5000
Answer:

#include <stdio.h>
int main()
{
int hundreds,tens,ones;
int price;
int money;

scanf("%d",&hundreds);
scanf("%d",&tens);
scanf("%d",&ones);
scanf("%d",&price);

money = hundreds*100 + tens*10 + ones;

if( price <= money){
printf("1");
}
else{
printf("0");
}

return 0;
}
0% Complete