# TCS NQT CARS AND BIKES CODING PROBLEM

We at gradjobopenings.com provide free job alerts of freshers job drives. In this website we list on campus job openings for freshers and off campus job openings for freshers and also work from home job openings. This is the best website to apply for off campus drive in India. Visit our website for government job alerts and private job alerts. We also list free interview notes and study materials, one of the best interview study website.comfortable to face the interviews:

Problem Statment

A new automobile company manufactures both two-wheeler (TW) and four-wheeler (FW). Unfortunately, there is no monitoring system placed to count the number of two-wheelers and the number of four-wheelers separately but there is a system that counts the total number of vehicles produced per day. There is also a system that counts the number of tyres manufactured a day. Given the number of vehicles manufactured and the number of wheels consumed, print the number of two-wheelers and the number of four-wheelers the company has produced on the given day.

**Sample input**:

– First line: A single, non-negative integer value V that denotes the number of vehicles manufactured the given day.

– Second line: A single, non-negative integer value W that denotes the number of tyres consumed to manufacture V vehicles.

**Sample output**:

– First line: Number of two-wheelers.

– Second line: Number of four-wheelers.

**Constraints:**

“`

2 <= W

W % 2=0

V < W

“`

– Print “INVALID INPUT”, if inputs did not meet the constraints.

**Example**

– Input :

“`

200

540

“`

– Output :

“`

130

70

“`

– Explanation:

– 130+70 = 200 vehicles

– (70*4)+(130*2)= 540 wheels

Program in C

#include <stdio.h>

int main() {
int vehicles, wheels;
scanf("%d%d", &vehicles, &wheels);
if (wheels & 1 || wheels < 2 || wheels <= vehicles) {
printf("INVALID INPUT");
return 0;
}
int wheels_cars = vehicles * 4; // Number of expected wheels if all given vehicles are to be cars.

int surplus_wheels = wheels_cars - wheels; // If all the vehicles were to be cars,
// number of extra wheels that would be required more than given wheels.

int no_of_bikes = surplus_wheels / 2;
int no_of_cars = vehicles - no_of_bikes;

printf("%d\n%d", no_of_bikes, no_of_cars);
return 0;
}

Program in C++

#include <iostream>
int main() {
int vehicles, wheels;
std::cin >> vehicles >> wheels;
if (wheels & 1 || wheels < 2 || wheels <= vehicles) {
std::cout << "INVALID INPUT";
return 0;
}
int wheels_cars = vehicles * 4; // Number of expected wheels if all given vehicles are to be cars.

int surplus_wheels = wheels_cars - wheels; // If all the vehicles were to be cars,
// number of extra wheels that would be required more than given wheels.

int no_of_bikes = surplus_wheels / 2;
int no_of_cars = vehicles - no_of_bikes;

std::cout << no_of_bikes << std::endl << no_of_cars;
return 0;
}

Program in JAVA

import java.util.Scanner;

class Main {
public static void main (String args[]) {
Scanner in = new Scanner(System.in);
int vehicles = in.nextInt();
int wheels = in.nextInt();
in.close();
if (wheels % 2 == 1 || wheels < 2 || wheels <= vehicles) {
System.out.print("INVALID INPUT");
return;
}
int wheels_cars = vehicles * 4; // Number of expected wheels if all given vehicles are to be cars.

int surplus_wheels = wheels_cars - wheels; // If all the vehicles were to be cars,
// number of extra wheels that would be required more than given wheels.

int no_of_bikes = surplus_wheels / 2;
int no_of_cars = vehicles - no_of_bikes;
System.out.print(no_of_bikes + "\n" + no_of_cars);
}
}

Program in Python

if __name__ == "__main__":
vehicles = int(input())
wheels = int(input())
if (wheels & 1 == 1 or wheels < 2 or wheels <= vehicles):
print("INVALID INPUT")
exit(0)

wheels_cars = vehicles * 4; # Number of expected wheels if all given vehicles are to be cars.

surplus_wheels = wheels_cars - wheels; # If all the vehicles were to be cars,
# number of extra wheels that would be required more than given wheels.

no_of_bikes = surplus_wheels // 2
no_of_cars = vehicles - no_of_bikes

print(int(no_of_bikes))
print(int(no_of_cars), end='')