Zahoor Ahmad

 

Home

C/C++

TQM

Data Analysis

Statistics

Computer

Contact

 

Computer Programming (C & C++)-1564

Problems for Practice of Functions :-

1

 

Write a program that produces the following table of temperature in Centigrade and Fahrenheit from 0 degree to 50 degree Centigrade using a function for conversion.

Centigrade

Fahrenheit

0

5

10

.

.

.

50

32

41

50

.

.

.

122

 

 

 

 

 

 

 

2

  Write functions to find factorial, number of combinations and number of permutations. Also write a driver program to test these functions

 

   

 

   

3

 

Write a function integerpower(base, exponent) that returns the value of baseexponent. Use this function in a program that inputs pairs of integers from user for calculation of power.

 

   

4

  The greatest common divisor (GCD) of two integers is the largest integer that divides each of the numbers. Write a function GCD that returns the greatest common divisor of the two numbers. Use this function in a program that inputs pairs of integers from user for calculation of GCD.

 

   

 

 

5

  Write a C++ program to determine the area and perimeter of rectangle according to the length and width entered by the user. Your code should make use of function to find area and perimeter.

     

6

  Write a program to calculate and display the area and circumference of a circle. The user gives radius of the circle. Area and circumference to be calculated using function.
     

7

  Write a program to simulate the tossing of a pair of dice 500 times. Count the frequency of each sum of faces for these 500 tosses.

 

   

8

 

Using the GCD function created above to find Least Common Multiple of two  positive integers.

 

   

9

  Write and test the following computeMeans() function that returns the arithmetic mean a, the geometric mean g and the harmonic mean h of up to three positive numbers.

void computeMeans(float& a, float& g, float& h, float x1, float x2 = 0, float x3=0)

 

 

   

10

   
     
     
     
     

 

 

The End

 



 

If you find any advertisement showing some indecent material please report its web address (URL) on contact page. It will help us to block such websites to show their ads in future. Sorry for inconvenience.