Problem Description
Arun has given half of the amount to his friends whenever he met his friends, the money left in arun hand is passed as the input and the number of friends be who receive the money as a input, you should print the inital amount arun had in his hand. Use structure to implement the code.
Input Method
Integers of values of amount and number of friends
Output Method
Initial amount of Arun
Explanation:
Suppose Arun have Rs.100 in his hand at the end, gave money to 2 friends refers the initial amount
calculated by 100*2=200, 200*2=400, so initial amount of Arun is Rs.400.Test Case 1
Input (stdin)100 2
Expected Output400
Test Case 2
Input (stdin)100 5
Expected Output2500
Program
#include <stdio.h> int main() { int a,b,i=0,c,d; scanf("%d%d",&a,&b); c=a*2; d=c; while(i<b-1) { d=d*2; i++; } printf("%d",d); return 0; }
No comments:
Post a Comment
Note: only a member of this blog may post a comment.