Canteen Expense

A student has Rs.100 in hand. He buys snacks for X rupees from the canteen. The program must print the amount remaining with the student.

Note: The program must accept the value of X as the input.

Example Input/Output 1:
Input:
60

Output:
40

Example Input/Output 2:
Input:
75

Output:
25

Python

X = int(input())
print(100-X)

Java

import java.util.*;
public class Hello {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.print(100 - N);
    }
}

C

#include <stdlib.h>
#include  <stdio.h>
int main()
{
    int X;
    scanf("%d", &X);
    printf("%d", 100-X);
    return 0;
}

C++

#include <iostream>
using namespace std;
int main()
{
    int X;
    cin >> X;
    cout << 100 - X;
    return 0;
}

Leave a Reply

Your email address will not be published. Required fields are marked *

More posts. You may also be interested in.