Shopping Change CodeChef Solution

Problem – Shopping Change CodeChef Solution

Chef went shopping and bought items worth X rupees (1≤X≤100). Unfortunately, Chef only has a single 100 rupees note.

Since Chef is weak at maths, can you help Chef in calculating what money he should get back after paying 100 rupees for those items?

Input Format

  • First line will contain T, the number of test cases. Then the test cases follow.
  • Each test case consists of a single line containing an integer X, the total price of items Chef purchased.

Output Format

For each test case, output in a single line the money Chef has to receive back.

Constraints

  • 1≤T≤100
  • 1≤X≤100

Sample 1:

Input: 3
1
25
100
Output: 99
75
0

Explanation:

Test case-1: Since chef paid 100 rupees for items worth 1 rupee. He should get back 99 rupees.

Test case-2: Since chef paid 100 rupees for items worth 25 rupees. He should get back 75 rupees.

Shopping Change CodeChef Solution in C++17

#include <iostream>
using namespace std;

int main() {
	// your code goes here
	int T;
	cin>>T;
	while(T--)
	{
	    int X;
	    cin>>X;
	    cout<<(100-X)<<endl;
	}
	return 0;
}

Shopping Change CodeChef Solution in Pyth 3

# cook your dish here
n=int(input())
for i in range(n):
    b=int(input())
    print(100-b)

Shopping Change CodeChef Solution in Java

/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		while(t>0){
		    int x = sc.nextInt();
		    System.out.println(x<=100?100-x:0);
		    
		    t--;
		}
	}
}
Shopping Change CodeChef Solution Review:

In our experience, we suggest you solve this Shopping Change CodeChef Solution and gain some new skills from Professionals completely free and we assure you will be worth it.

If you are stuck anywhere between any coding problem, just visit Queslers to get the Shopping Change CodeChef Solution

Find on CodeChef

Conclusion:

I hope this Shopping Change CodeChef Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Coding Solutions.

This Problem is intended for audiences of all experiences who are interested in learning about Data Science in a business context; there are no prerequisites.

Keep Learning!

More Coding Solutions >>

LeetCode Solutions

Hacker Rank Solutions

CodeChef Solutions

Leave a Reply

Your email address will not be published.