Function and Array
1. WAP to swap two numbers using function.
2. WAP using function which outputs all the prime numbers between 2 and a given positive integer n:
Hint:
void Primes (unsigned int n);
A number is prime if it is only divisible by itself and 1.
3. WAP to define an enumeration called Month for the months of the year and use it to define a function which takes a month as argument and returns it as a constant string.
4. WAP to define a recursive version of the Power function
5. WAP to write a function which returns the sum of a list of real values
Hint:
double Sum (int n, double val ...);
where n denotes the number of values in the list.
6. The following table specifies the major contents of four brands of breakfast cereals.
Define a two-dimensional array to capture this data:
------------Fiber ----Sugar-----Fat------Salt
Top Flake--12g------25g -------16g-----0.4g
Cornabix---22g-------4g --------8g-----0.3g
Oatabix-----28g ------5g---------9g-----0.5g
Ultrabran---32g------7g---------2g------0.2g
Write a function which outputs this table element by element.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment