0% found this document useful (0 votes)
25 views1 page

Document From ?

The document discusses rewriting C functions related to character manipulation, reading and displaying integers, calculating factorials and Newton's coefficient, and performing operations on complex numbers. It provides examples of functions to rewrite, write from description, and use in programs to demonstrate summing integers, factorials, and complex number math.

Uploaded by

seklawifatimah2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views1 page

Document From ?

The document discusses rewriting C functions related to character manipulation, reading and displaying integers, calculating factorials and Newton's coefficient, and performing operations on complex numbers. It provides examples of functions to rewrite, write from description, and use in programs to demonstrate summing integers, factorials, and complex number math.

Uploaded by

seklawifatimah2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Functions

I. Rewrite the following C functions:


- char TOLOWER(char) converts parameter to lower case
- char TOUPPER(char) converts parameter to upper case
- int IsAlpha(char) 1 when the parameter is alphabetic, 0 otherwise
- int IsDigit(char) 1 when the parameter is a digit, 0 otherwise
- int IsAlphNum(char) 1 when the parameter is alphanumeric, 0 otherwise
- int SIGN(float) -1 when the parameter is negative, 0 when null, and +1 when
positive
- double ABS(double): absolute value of the parameter
- double CEIL(double) smallest integer not less than parameter
- double FLOOR(double) largest integer not greater than parameter

II. Write the following:


a. A function Read_Integer that reads a non zero positive integer from the user and returns it,
b. A function Print_Integer that takes an integer as a parameter and displays it on the screen,
c. A function Sum_Integer that takes two integer parameters and returns their sum,
d. A C program that uses all the above to:
- Read two positive non zero integers from the user,
- Calculates their sum,
- Displays the calculated sum

III. Write a function Fact that returns N! = 1*2*3*…*(n-1)*n.


Where N is an integer.

Write a C program that uses the previous function Fact to calculate the coefficient of Newton C np

IV. A complex number is defined by a real part and an imaginary part.


a. Write the proposed data structure for a complex number,
b. Write a function Complex_Addition that takes two complex numbers as parameters and
returns their sum.
c. Write a function Complex_Multiplication that takes two complex numbers as parameters and
returns their product.
d. Write a function Display_Complex that takes a complex number as a parameter ans displays
it in its complex form.
e. Write in two different methods, a function Read_Complex that reads a complex number from
the user.
f. Write a C program that uses the previous functions to read two complex numbers and to
display their sum and their product.

You might also like