CBP list
CBP list
Rahul manages a car service facility and wants to calculate the service charges
for cars based on the time they have spent at the facility. The program takes the
number of cars 'n' and the hours each car has been at the facility.
Write a program that assists Raveena in counting and displaying the number of
negative elements in an integer array.
Input Format
The first line of input consists of an integer n, representing the number of
elements in the array.
The second line of input consists of n space-separated integers, representing the
elements of the array.
Output Format
If there are no negative elements in the array, the output prints "No negative
elements in the array".
Otherwise, the output prints "Total negative elements in array = " followed by an
integer which is the total count of negative elements in the array.
Refer to the sample output for the formatting specifications.
Constraints
In this scenario, the test cases will fall under the following constraints:
3 ≤ n ≤ 10
-1000 ≤ elements ≤ 1000
Sample Input - 1
10
10 -2 5 -20 1 50 60 -50 -12 -9
Sample Output -1
Total negative elements in array = 5
Sample Input - 2
5
63219
Sample Output - 2
No negative elements in the array
Sample Input - 3
3
-1000 -99 1000
Sample Output -3
Total negative elements in array = 2
Time Limit: - ms Memory Limit: - kb Code Size: - kb
For each segment, input the distance travelled (in kilometres) and the speed (in
kilometres per hour) of the vehicle. Calculate the total distance travelled and the
total time taken by all vehicles in the fleet.
Jonathan needs assistance in creating the program using loops to accomplish his
task.
Input Format
The input consists of an integer N, representing the number of terms the sum is
to be calculated.
Output Format
The output prints "Sum of the series: " followed by an integer representing the
total sum.
Since she finds this calculation as a complicated process, she seeks your help in
developing the program. Assist her in completing the program using looping
statements.
Example
Input:
M = 123
N=2
Output:
Step 1: 6
Final result after multiplying by 2: 12
Explanation:
The initial value of M is 123 and the multiplier N is 2. The multiplicative
persistence of 123 is 1, as it takes one step to multiply its digits (1 * 2 * 3 = 6)
and obtain a single-digit number. Then, the final result is obtained by multiplying
the persistence result (6) by the multiplier N (2), resulting in a final product of
12.
Input Format
The first line of input consists of an integer M.
The second line of input consists of an integer N.
Output Format
For each step, the output prints "Step X: Y", where X represents the current step
count, and Y represents the current product value after computing the product of
its digits.
After the loop terminates, the output prints "Final result after multiplying by N: "
followed by an integer representing the final product value.
Write a program to obtain N and X as input from the user and print the sum of all
the integers less than N(exclusive) that are divisible by X.
Input Format
The input consists of two integers N and X in separate lines.
Output Format
The output prints the sum of all the integers less than N (exclusive) that are
divisible by X.
1. If the player completes the level in the first attempt, they earn 10 times
the bonus points.
2. If the player completes the level in the second attempt, they earn 5 times
the bonus points.
3. If the player fails to complete the level within the maximum attempts
allowed, the program skips to the next level.
Input Format
The first line of input consists of a positive integer, P representing the bonus
points awarded for each level.
The second line of input consists of a character (Y for Yes, N for No) representing
the player's first attempt to complete a level.
If the second line of input is 'N', the third line of input consists of another
character(Y for Yes, N for No) representing the result of the second attempt.
Output Format
The output prints one of the following:
James is working on a fitness app that helps weightlifters track their progress.
One of the app's essential features is that it allows users to enter the weight they
lift in pounds and then display the weight in kilograms for accurate tracking.
Write a program that takes the weight lifted in pounds as input and converts it to
kilograms as float using the type conversion factor
Write a program that takes a single character as input from the user. The
program should then convert the character to its ASCII value using the Type
conversion and display it. Also, the output should print the next character of the
given input.
Input Format
The input consists of a character.
Output Format
The first line prints the ASCII value of the input character.
The second line prints the next character of the given input.
At the community center’s crafting workshop, you need to determine the final
cost of a new material based on its dimensions. First, calculate the initial cost by
multiplying the length and width of the material, resulting in a floating-point
number. This initial cost is then converted to an integer for further adjustments.
Based on the user’s choice, adjust the integer value as follows: If the choice is 1,
add 5 to the converted integer. If the choice is 2, subtract 5 from it. If the choice
is 3, divide the converted integer by 2. The choice is indicated by an integer
input (1, 2, or 3).
Your task is to output the initial cost formatted as a floating-point number with
two decimal places and the final adjusted integer cost according to the chosen
operation.
Input Format
The first line consists of two space-separated float values num1 and num2,
representing the first and second dimensions of the material.
The second line contains an integer choice, which indicates the adjustment
operation to be performed (1, 2, or 3).
Output Format
The first line displays "Multiplication Result (as float): " followed by the result of
multiplying num1 and num2 as a float value with two decimal values.
The second line displays "Converted Integer: " followed by the result as an
integer value after performing the required operation on the converted result
based on the choice.
Design a program for the coffee shop's caffeine tracking system. The program
should prompt the user to enter the caffeine content of a beverage in milligrams
and then display the equivalent caffeine content in grams.
Write a program that takes the input for the caffeine content in milligrams,
converts it into grams as float using type conversion, and prints the two decimal
points with the grams.
Input Format
The input consists of an integer representing the caffeine content of a beverage
in milligrams.
Output Format
The output displays the equivalent caffeine content in grams as a float value,
rounded off 2 decimal points.
Constraints
0 <= milligrams <= 1000
Sample Input 1
10
Sample Output 1
0.01
Sample Input 2
500
Sample Output 2
0.50
Implement a program that takes Fin's salary as input (integer) and calculates the
net salary after converting it into float.
Input Format
The input consists of an integer value n, representing Fin's monthly salary.
Output Format
If no tax is applicable, the output prints "No Tax"
If a tax is applicable, the output prints "Salary after X% Tax: Y" where X
represents the applicable tax percent value and Y represents the net salary after
deduction with two decimal places.
Problem Statement - 17
Ria is a football enthusiast who wants to keep track of her favourite team's
performance in a tournament. She needs to develop a program that calculates
the total points earned by the team based on the outcomes of their matches.
In the tournament, a win earns the team 3 points, a draw earns them 1 point,
and a loss earns them 0 points. As a programmer, assist Ria in developing the
program.
Example
Input:
5
20121
Output:
Total points: 8
Explanation:
Match 1: Win - 3 points
Match 2: Loss - 0 point
Match 3: Draw - 1 point
Match 4: Win - 3 points
Match 5: Draw - 1 point
Total points = 3 + 0 + 1 + 3 + 1 = 8 points.
Input Format
The first line of input consists of an integer N, representing the number of
matches played by the team.
The second line consists of N space-separated integers, representing the
outcome of each match (0, 1, or 2), where 0 means a loss, 1 means a draw and 2
means a win.
Output Format
The output prints "Total points: " followed by the total number of points earned
by the team in the tournament.
Problem Statement - 18
She requires a program wherein she can input three integers: N representing the
limit, M representing one multiple, and P representing another multiple. Upon
execution, the program should output the sum of these multiples within the
given limit for Claire's analysis.
Input Format
The input consists of three space-separated integers: an integer N representing
the limit, an integer M representing one of the multiples, and an integer P
representing another multiple.
Output Format
The output displays an integer which is the calculated sum.