Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search & Filtering

Instructions:



Using a do...while() loop, continuously scan for random integers that will be inputted by the user and print out its square, separated in each line.


Once the inputted value is 0, it will still print out its square value but should then terminate the loop afterwards. Use this concept in making your loop condition.


Input



1. Series of integers



Output



Multiple lines containing message prompts for integers and their squares.



Enter·n:·2


Square·=·4



Enter·n:·6


Square·=·36



Enter·n:·0


Square·=·0

given a of M numbers and a postive integers N, print the sum of numbers whose position in the list is divisible by N .consider that the position of numbers range from 1 to N


INPUT:

the first line contains two-spaced integers N,M

the second line contain M space-seperated integers.


output:

print a single integer representing the requried sum


explanation:

Sample Output1

Given N=1 , M=7

and the number_list=[4,8,6,6,7,9,3]

As every position is divisible by1,

4+8+6+6+7+9+3=43

so the output should be 43


Triples with Properties


Shikhar has two integers S and T. Now, he wants to count al possible triplets of non-negative integers (a, b, c) which satisfy


the below conditions:


-a+b+c<= S -axbxc<=T


Your task is to help him by finding the count of such triplets of non negative integers (a, b, c)


reture cont


T


13 printfomet trip


Input


The only line of input contains two space separated integers S and T


Output


Print the count of triplets of non-pegative integers (a, b, c) satisfying the conditions


Explanation


In the first example, we have $1 and T. O eve 4 triplets of non-negative integers which have the above properties (0,0,0) (0,01), (010) and (100) Therefore, the output is 4


Esc FrLock


2


4


12


4+


Ajith is a raw agent and he is going on a secret mission.He needs your help but you have yo learn how to encode a secret message yo communicate safely with other agents




Cipher with Key





A Keyword Cipher is a monoalpha





uses a key to provide en ption





In a substitution cipher each letter of





matched with a different letter accord to phetet





Using these letter matchings, every letter of the esse





substituted to get the encrypted messag





In a keyword cipher, the key determines the let he ciphertext alphabet is created by keeping the lette the beginning (after removing the repeated letters then the rest of remaining letters are used in aph





For example, if the key is zebras





Plaintext Alphabet: albicidjeifigibili Ciphertext Alphabet : zjelb/r/als/cidition





Notice that with this key, we are able to match each lecer of engl alphabet with a different letter. Using these matchings we can encrypt the word discovered as rpbluacerda





replaced with f,i is replaced with and soon





Given a key K and the message M, encrypt the message Keyword Cipher, using the given key





Input





The first tine contains two

Krishna owns n mobile phones (numbered 1 through n) he wishes to sell all of them in the coming next N years by selling exactly 1 mobile per year. The initial price of each mobile phone is pi . Due to depreciation , the price of each mobile phone decreaes by 2500 rupees per year untill sold.





Note that price of a mobile cannot drop below 1000 rupees no matter how many years have passed , ie when the price of a mobile reaches 1000 rupees in some years , it remains 1000 in all subsequent years .





Find max amount krihna can make by selling his mobile phones





Input




The first line contains a single integer t denoting the number of test cases




The first line of each test case contains a single integer n




The second line of the each test case contains n space seperated integers p1,p2,.....,pn





Output




For each test case , print a single line containing an integer

Evolution stage



If N is even N/2



If N is odd N * 3+1 and point steps to reach 1 . Ex: 10is even 10/2=5, 5 is odd 5*3+1=16, 16 is even 16/2= 8 and 8/2=4 and 4/2= 2 and 2/2 =1



So the output is 6

Discount sale



Input 1


4


1 1 2 2


Output 1


4



Input 2


2


10 200


Output 2


210

krishna owns N mobile phones (numbered 1 through N) He wishes to sell all of them in the coming next N years by selling exactly one mobile per year.

N = 3 

mobile prices = [60000, 60000, 60000]


depreciating 1000rs per every year after selling each mobile 


first year mobile price = 60000

second-year decreasing = 1000 depreciation 



in this way he sold the mobiles could you please resolve my query



The function Power, which raises the integer number x to the power n, can be defined recursively as follows:

Power(x, n) = 1 for n = 0

Power(x, n) = x * Power(x, n-1) for n > 0

(i) Using the above definition write the recursive function Power(x, n) in C.

(ii) Rewrite the recursive function Power(x, n) in an iterative form.

(iii) Write the main function and test the above-written functions. Note: You can write one program and test the functions or you may write two separate programs for each part (i) and (ii). 


LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS