Practice Top 30 C++ Programming Questions on Maths, TechnoVlogs

Practice Top 30 C++ Programming Questions on Maths


Q1. Use sqrt() to find the square root of a number.

Input:  
Number: 16

Expected Output:  
Square Root: 4

Q2. Use pow() to calculate a number raised to a power.

Input:  
Base: 2  
Exponent: 3

Expected Output:  
Result: 8

Q3. Use abs() to find the absolute value of a number.

Input:  
Number: -25

Expected Output:  
Absolute Value: 25

Q4. Use round() to round a floating-point number.

Input:  
Number: 4.7

Expected Output:  
Rounded Value: 5

Q5. Use floor() to find the largest integer less than or equal to the number.

Input:  
Number: 5.8

Expected Output:  
Floor Value: 5

Q6. Use ceil() to find the smallest integer greater than or equal to the number.

Input:  
Number: 2.3

Expected Output:  
Ceiling Value: 3

Q7. Use log() to find the natural logarithm of a number.

Input:  
Number: 2.718

Expected Output:  
Natural Log: 1

Q8. Use log10() to find the base-10 logarithm of a number.

Input:  
Number: 100

Expected Output:  
Log10 Value: 2

Q9. Use sin() to calculate the sine of an angle in radians.

Input:  
Angle: 1.5708

Expected Output:  
Sine: 1

Q10. Use cos() to calculate the cosine of an angle in radians.

Input:  
Angle: 0

Expected Output:  
Cosine: 1

Q11. Use tan() to calculate the tangent of an angle in radians.

Input:  
Angle: 0.7854

Expected Output:  
Tangent: 1

Q12. Use rand() to generate a random number between 1 and 100.

Expected Output:  
Random Number: 42 (Example output)

Q13. Use fmax() to find the larger of two numbers.

Input:  
Numbers: 12, 25

Expected Output:  
Maximum: 25

Q14. Use fmin() to find the smaller of two numbers.

Input:  
Numbers: 12, 25

Expected Output:  
Minimum: 12

Q15. Use hypot() to find the hypotenuse of a right triangle.

Input:  
Sides: 3, 4

Expected Output:  
Hypotenuse: 5

Q16. Use M_PI and a formula to convert degrees to radians.

Input:  
Degrees: 90

Expected Output:  
Radians: 1.5708

Q17. Use a formula to convert radians to degrees.

Input:  
Radians: 1.5708

Expected Output:  
Degrees: 90

Q18. Use exp() to calculate e^x.

Input:  
x: 2

Expected Output:  
Exponential Value: 7.3891

Q19. Use % to find the remainder of division.

Input:  
Numbers: 10, 3

Expected Output:  
Remainder: 1

Q20. Use cbrt() to find the cube root of a number.

Input:  
Number: 27

Expected Output:  
Cube Root: 3

Q21. Generate a random floating-point number between 0 and 1 using rand().

Expected Output:  
Random Float: 0.56 (Example output)

Q22. Write a program to compute the factorial of a number.

Input:  
Number: 5

Expected Output:  
Factorial: 120

Q23. Use fmod() to calculate the modulus of floating-point numbers.

Input:  
Numbers: 5.5, 2.1

Expected Output:  
Remainder: 1.3

Q24. Use fabs() to find the absolute value of a floating-point number.

Input:  
Number: -12.3

Expected Output:  
Absolute Value: 12.3

Q25. Write a program to calculate compound interest.

Input:  
Principal: 1000  
Rate: 5%  
Time: 2 years

Expected Output:  
Compound Interest: 102.5

Q26. Use nearbyint() to round to the nearest integer.

Input:  
Number: 4.5

Expected Output:  
Nearest Integer: 4

Q27. Use a formula to find the square of a number.

Input:  
Number: 7

Expected Output:  
Square: 49

Q28. Evaluate a polynomial using math functions.

Input:  
x: 2  
Equation: x^2 + 2x + 1

Expected Output:  
Polynomial Value: 9

Q29. Use gcd() to find the greatest common divisor.

Input:  
Numbers: 48, 18

Expected Output:  
GCD: 6

Q30. Use a formula to calculate the least common multiple.

Input:  
Numbers: 4, 6

Expected Output:  
LCM: 12

Social Share

Bikki Singh Instructor TechnoVlogs

Bikki Singh

Hi, I am the instructor of TechnoVlogs. I have a strong love for programming and enjoy teaching through practical examples. I made this site to help people improve their coding skills by solving real-world problems. With years of experience, my goal is to make learning programming easy and fun for everyone. Let's learn and grow together!