Posts

Showing posts with the label C programming

Finding Square Roots solution in C language - Codechef

   Finding Square Root Problem Code:  FSQRT In olden days finding square roots seemed to be difficult but nowadays it can be easily done using in-built functions available across many languages  . Assume that you happen to hear the above words and you want to give a try in finding the square root of any given integer using in-built functions. So here's your chance. Input The first line of the input contains an integer T, the number of test cases. T lines follow. Each line contains an integer N whose square root needs to be computed. Output For each line of the input, output the square root of the input integer, rounded down to the nearest integer, in a new line.. Constraints 1<=T<=20 1<=N<=10000 Example - Incorrect Withdrawal Amount (not multiple of 5) Input: 3 10 5 10000 Output: 3 2 100 . . . Solution in C. # include <st dio.h> # include <math .h> i nt mai n () { int t, a; scanf ( " %d " ,&t); whilef ( t -- ) { ...

Bella Ciao solution in C language.- Codechef

   Bella Ciao Problem Code: CHFHEIST Chef is planning a heist in the reserve bank of Chefland. They are planning to hijack the bank for  � D  days and print the money. The initial rate of printing the currency is  � P  dollars per day and they increase the production by  � Q  dollars after every interval of  � d  days. For example, after  � d  days the rate is  � + � P + Q  dollars per day, and after  2 � 2 d  days the rate is  � + 2 � P + 2 Q  dollars per day, and so on. Output the amount of money they will be able to print in the given period. Input Format The first line contains an integer  � T , the number of test cases. Then the test cases follow. Each test case contains a single line of input, four integers  � , � , � , � D , d , P , Q . Output Format Output For each test case, output in a single line the answer to the problem. Constraints 1 ≤ � ≤ 1 0 5 1 ≤ T ≤ 1 0 5 1 ≤ � ≤ � ≤ 1 0...