Question: Talent Show
Mountain
View Middle School is all set for organizing their elaborate talent
show event of the year, "Stars Onstage". It is a fun-filled event for
the students to showcase and build their confidence.
Of the total audience who had come for the show, 1/3 were boys, 3/6 were girls and the rest of them were adults. If there were 'x' more girls than adults, how many people were there in total? Help the School authorities to find the total people who visited their show.
Input Format:
First line of the input is an integer 'x', which corresponds to the count of girls more than adults.
Output Format:
Output the total number of people who had visited the talent show.
Refer sample input and output for formatting specifications.
[All text in bold corresponds to input and rest corresponds to output.]
Sample Input and Output1:
Enter x
50
150 people were there in total
Sample Input and Output2:
Enter x
70
210 people were there in total
Solution:
#include<stdio.h>
int main()
{
int x,t,b,g,a;
printf("Enter x");
scanf("%d",&x);
b=x;
g=(3*x)/2;
a=x/2;
t=b+g+a;
printf("\n%d people were there in total",t);
return 0;
}
int main()
{
int x,t,b,g,a;
printf("Enter x");
scanf("%d",&x);
b=x;
g=(3*x)/2;
a=x/2;
t=b+g+a;
printf("\n%d people were there in total",t);
return 0;
}
Can u explain the method
ReplyDeleteCan you please explain the logic used?
ReplyDeleteNice Blog. Thanks for sharing with us. Such amazing information.
ReplyDeleteWhat are the benefits of residential schools?
""Kids on the Move" is a challenging game show organized for kids from age 10 to 15 years. Eddy and Sarah participated at the show and progressed to the semi-finals. At the semi-finals, they were given two vessels, one of which can accommodate a litres of water and the other - b litres of water. The challenge to them was to determine the number of steps required to obtain exactly c litres of water in one of the vessels.
ReplyDeleteAt the beginning both vessels are empty. The following operations are counted as 'steps':
emptying a vessel,
filling a vessel,
pouring water from one vessel to the other, without spilling, until one of the vessels is either full or empty.
Help the kids clear the challenge and progress to the finals. Write a recursive function to find the number of steps required to obtain exactly c litres of water in one of the vessels.
C Function Specifications:
Use the function name, return type and the argument type as:
int minSteps(int,int,int)
The Function should return the minimum number of steps required to obtain c litres, or return -1 if this is impossible.
Input Format:
There are three lines of the input which contains three positive integers a, b and c respectively.
Output Format:
Output the minimum number of steps required to obtain c litres, or -1 if this is impossible.
Refer sample input and output for formatting specifications.
Sample Input 1:
5
2
3
Sample Output 1:
2
Sample Input 2:
2
3
4
Sample Output 2:
-1
code??
DeleteJava
ReplyDelete