Programming does not always happen smoothly, sometimes a lot of patience, devotion and perseverance are required to solve programming problems and stumbling blocks on your way of creating a new programming solution.While developing an application you might come across a number of programming questions the answers to which are not easy to be found. To spare yourself the trouble, submit your programming questions here and you will get programming answers within the shortest time period.
You are so lucky in 2021 and finally you have bought your dream car. You decided to travel to many cities. The car tank capacity is C litres. And each trip will cost x liters of fuel. You can fill the tank when visiting each city. The expected inputs N : number of cities C : Tank capacity A[]: the fuel amount you can fill from each city B[]:the fuel consumption to travel from city i and city i+1 The output The maximum number of cities you can travel
What is the value of f(846) for the function below?
def f(x):
d=0
y=1
while y <= x:
d=d+1
y=y*3
return(d)
Write a program to get the purchasing and selling price of a product and calculate its profit when 5 products are sold.
Write a C++ program in which, read a c-string from user. Now your task is to replace all possible pairs of character from input string
Consider the following function mys:
def mys(m):
if m == 1:
return(1)
else:
return(m*mys(m-1))
Which of the following is correct?
The function always terminates with mys(n) = factorial of n
The function always terminates with mys(n) = 1+2+...+n
The function terminates for non-negative n with mys(n) = factorial of n
The function terminates for positive n with mys(n) = factorial of n
For what value of n would g(57,n) return 7?
def g(m,n):
res = 0
while m >= n:
res = res+1
m = m-n
return(res)
What is h(41)-h(40), given the definition of h below?
def h(n):
s = 0
for i in range(1,n+1):
if n%i > 0:
s = s+1
return(s)
Initialize a string of size 40. Write a program that prints all unique alphabets from string. After printing them sort them in ascending order.
For example: Hi world I am here to help you.
Unique characters are: H, I, W, O, R, L, D, A, M, E, T, P, Y, U.
Sorted: A, D, E, H, I , L,M, O, P, R, T, U, W, Y
University of Central Punjab (UCP) is arranging a competition of programming, in which IT department student can participate. In this competition student will be asked questions (True/False) and student will be given points, in the end student whose points are higher will be winner. Student whose marks are second highest is called runner up.
You are required to simulate this scenario using C++.
● User will enter 3 options either True (T), False (F) or space for each question. As shown below
T
F
T
T
F
T
T
F
T
The answer to question 1 is true, the answer to question 2 is False, and student did not answer question 4. The exam has 10 questions.
● Each correct answer is awarded two points, each wrong answer gets one point deducted, and no answer gets zero points.
● Assume there are 10 students so you have to ask 10 strings of True false as seen above. Before entering answer ask user to write his/her serial number. So you have two array one contain roll number and one contains marks of each student. This concept is called parallel array. Note: please make sure using programming, that user should enter a unique serial#, if it selects a previously available serial#, tell /her to enter again.
● Generate a random key that have correct answers in order to give students marks.
Tasks to be done:
Q1. Print winner and runner up serial# along with marks
Q2. Print all participants serial # and marks in descending order(parallel sorting)
Q3. Print average of marks of all students
Sample Output: (for 3 students)
F
F
T
T
T
T
T
F
T
Please enter your serial Number: 123
Please enter questions answers:
Please enter your serial Number: 123
Sorry this serial number is already present! Enter again: 453
T
F
F
T
T
T
T
T
F
T
Please enter questions answers:
Please enter your serial Number: 143
F
T
F
T
F
F
F
F
F
T
Please enter questions answers:
F
T
F
T
T
T
T
T
F
T
Answers to questions are:
Winner student is: 123 with marks 18
Runner up is: 453 with marks 14
Marks of Students are:
123 18
453 14
143 8
Average of marks is: 13.333
Initialize a string of size 40. Write a program that prints all unique alphabets from string. After printing them sort them in ascending order.
For example: Hi world I am here to help you.
Unique characters are: H, I, W, O, R, L, D, A, M, E, T, P, Y, U.
Sorted: A, D, E, H, I , L,M, O, P, R, T, U, W, Y