Monday 8 August 2011

[chapter 5 part 1]let us c [SOLVED]

[D] Answer the following:

(a)Write a function to calculate the factorial value of any integer entered through
the keyboard.


(b) Write a function power ( a, b ), to calculate the value of a raised to b


(c) Write a general-purpose function to convert any given year into its roman equivalent.
The following table shows the roman equivalents of decimal numbers:

Decimal:........Roman
1.....................i
5....................v
10..................x
50..................l
100................c
500...............d
1000.............m

Example:
Romanequivalent of 1988 is mdcccclxxxviii
Roman equivalent of 1525 is mdxxv


(d) Any year is entered through the keyboard. Write a function to determine whether the year is a leap year or not.


(e) A positive integer is entered through the keyboard. Write a function to obtain the prime factors of this number. For example, prime factors of 24 are 2, 2, 2 and 3, whereas prime factors of 35 are 5 and 7.

3 comments: