0% found this document useful (0 votes)
21 views2 pages

Sheet 2 (2024 2025)

Uploaded by

seifelshaa8
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)
21 views2 pages

Sheet 2 (2024 2025)

Uploaded by

seifelshaa8
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/ 2

Menoufia University Computer Programming

Faculty of Electronic Engineering AC Year: 2024/2025


Special Programs ‫جام عة الم نوف ية‬ 1st Semester

Sheet [2]: Functions

1. Write a C++ program to first allow a user to input two floating


numbers x and y from K.B. Then, call a function to add the two
numbers, call a second function to sub the two numbers, and call a
third function to multiply the two numbers. Finally, print the results
on the screen.

2. Write program to first allow a user to input two numbers x and y


from KB. Then, call a function to find and return the summation, the
subtraction, and the multiplication of the two numbers. Finally, from
the main function print the results on the screen.

3. Write a C++ program to first allow a user to input an integer


number n from KB. Then, call a function to find and return the
factorial of n. Finally, print the result on the screen.

4. Write a C++ program to first allow a user to input an integer


number n from K.B. Then, call a function to find and return the sum
of the values from 1 to n. Finally print the sum and the average on
the screen.

5. Write a C++ program to first allow a user to input two integer


numbers (A and B) from K.B. Then, call a function to find and return
the sum of the values from A to B. Finally print the sum and the
average on the screen.

6. Write a C++ program to first allow a user to input two integer


numbers (S and E) from K.B. Then, call a function to find and return
the sum of the even values from S to E. Finally print the sum and
the average on the screen.

7. Write a C++ program to first allow a user to input an integer number


n from K.B. Then, call a function called sum() to find and return the
sum of the odd values from 1 to n. Finally print the sum and the
average on the screen.

1
8. Write a C++ program to first allow a user to input three different
integer numbers from K.B. Then, call a function to find and return
the min value. Finally, print the min value on the screen.

9. Write a C++ program to first allow a user to input three different


integer numbers from K.B. Then, call a function to find and return
the largest value. Finally print the numbers and the largest value on
the screen.

10. Write a C++ program to first allow a user to input three different
integer numbers from K.B. Then, call a function called Min() to
find and return the min value and another function called Max()
to find and return the max value. Finally, print the min and the
max values on the screen.

11. Write a C++ program to first allow a user to input an integer


number n from KB. Then, by using recursion, call a function to
find and return the factorial of n. Finally, print the result on the
screen.

« With my best wishes »


Prof. Gamal ATTIYA

You might also like