C PROGRAMMING Preview Questions

Problem Statement :

A beer manufacturing company sells beer in bottles of different sizes - 1 Gallon, 5 Gallons, 7 Gallons and 10 Gallons. Given a supply order of N Gallons, the manufacturer wants to fulfil the demand with minimum number of bottles.
The function bottles_required() accepts 1 parameter: an int gallons_of_beer.
Complete the function bottles_required() by returning the minimum number of bottles required in integer format.

Example 1

Input: gallons_of_beer=17

Output: 2

Example 2

Input: gallons_of_beer=13

Output: 3

Problem Statement :

N people labeled from 1 to N are standing in a line from left to right wearing one between the 2 available jerseys. The person wearing jersey 1 passes the ball right to its right neighbor's neighbor. The person wearing jersey 2 passes the ball left to its neighbor.a string containing only 2 alphabets 'A' and 'B', where the character at the ith position represents the jersey of the ith person. (A: Jersey 1, B: Jersey 2).In how many passes can the ball reach from the leftmost person to the rightmost person?
The function calculate_passes() accepts the parameter str players.Complete the function by returning the number of passes required from left to right ,if no output is possible return -1 in integer format.

Example 1

Input: players=AABAAA

Output: 4

Example 2

Input: players=AAA

Output: 1

Fill up the form to continue :

Powered by