Wipro - C & C++ Coding Ability

Test Number 4


You are given the values of the principal amount (P), rate of interest (R), and time period (T). Your task is to print the compound interest for the given principal amount.


INPUT:
First Line of input contains 3 space-separated float values denoting the values of P, R, and T respectively.



OUTPUT:
Contains a float value denoting the value of compound interest for the given principal amount.



Test Case: 1

INPUT:
10 10 2

OUTPUT:

2.100001                

#include

#include

int main()

{

	float p,r,n,ci;

	scanf("%f%f%f",&p,&r,&n);

	ci=p*pow((1+r/100),n)-p;

	printf("%f",ci);

	

}               






You are given a value of temperature in degree celsius. Your task is to convert that value of temperature in Fahrenheit.

 Input:

First line of the input contains a integer value T i.e. test cases.

For each test case the next line contains an integer value of temperature in celsius.

Output:

It contains an integer value of final output.



Test Case: 1

INPUT:
1

32



OUTPUT:
89

Explanation:

By using conversion formula, when we give input of 32 in celsius the output will be 89 fahrenheit.                   

#include< bits/stdc++.h>

using namespace std;



double cToF(int C)

{

   return (1.8*C +32);

}



int main()

{

    int T;

    int C,F;

    cin >> T; 

    while(T--){

        cin >> C;

        cout << floor(cToF(C)) << endl; 

    }

    return 0;

}                   






You are given a positive integer N. Your task is to print all the prime numbers less than the given integer.

INPUT:
Contains the value of N.

OUTPUT:
contains all space-separated prime numbers .

 Test Case: 1

INPUT:
8

OUTPUT:
2 3 5 7

                          

#include 

using namespace std;



int isaprime(int);



int main() {

   bool geeksgod;

   int N;

   cin>>N;

   for(int n = 2; n < N; n++)

   {

       geeksgod = isaprime(n);



       if(geeksgod == true)

          cout< < n << " ";

   }

   return 0;

}





int isaprime(int n) {

   bool geeksgod = true;



   for(int i = 2; i <= n/2; i++) {

      if (n%i == 0)

      {

         geeksgod = false;

         break;

      }

   }

   return geeksgod;

}                          






You are given a positive integer N. Your task is to count that how many times the digit 3 will appear in that integer.

INPUT:
First Line of input contains T for the number of test cases. 

Next line of input contains T space separated integers containing the value of N.

 OUTPUT:
Contains T space separated integers indicates the count of digit 3 in that integer.



TEST CASE: 1

INPUT:
2

89 38

OUTPUT:
0 1                     

#include

using namespace std;

int main ()

{

    int T,N;



    cin>>T;



    while(T--)



    {



        cin>>N;



        int A;

        int count = 0;



        while(N>0)



        {



            A = N%10;

            if(A==3)

            {

                count = count + 1;

            }

            N=N/10;



        }



        cout << count << " ";

    }

    return 0;



}                             






You are given an integer value N. Your task is to find the number of digits that appear in the factorial in its factorial. 

Input:

First line of the input contains T i.e. number of test cases.

for each test case next line contains the value of N.

Output:

contains a single integer of output.



Test Case: 1

INPUT:

1

5

OUTPUT:

3

Explanation:

Factorial of 5 is 120.
Number of digits in 120 is 3 (1, 2, and 0)
                    

#include

using namespace std;



int digitsInFactorial(int N)

{

double count = 0;

for (int i=2; i<=N; i++)

count += log10(i);

return floor(count) + 1;

   

}





int main()

{

    int T;

    

    

    cin>>T;

    while(T--)

    {

        int N;

        

        

        cin>>N;

        

        

        cout << digitsInFactorial(N)<< endl;

    }

    return 0;

}