ةيندرلأا ةعماجلا / ةبقعلا Computer Skills Science Faculties ةداملا: لا جاحلا وبا نيدلارون: بلاط 3221499 بلاطلا: دئار دمحا 3221544 Exercises
ةيندرلأا ةعماجلا / ةبقعلا Computer Skills Science Faculties ةداملا: لا جاحلا وبا نيدلارون: بلاط 3221499 بلاطلا: دئار دمحا 3221544 Exercises
a. To use a predefined function in a program, you need to know only the name of the function
and how to use it
True
False.
output=3
e. static_cast<char>(tolower('T'))
output=t
EXERCISES (3). Determine the value of each of the following expressions. (For
decimal numbers, round your answer to two decimal places.)
output=11.16
i. floor(27.37)
output=27
Which of the following are correct function prototypes of the function funcTest?
****************************************************
The answer
****************************************** *
b. double funcTest(string n, char ch, int x, double t);
EXERCISES (11). Write the definition of a function that takes as input a char
value, and returns true if the character is a whitespace character; otherwise
it returns false.
#include <iostream>
return true;
else
return false;
int main(){
char num;
cin.get(num);
if (whitespce(num))
else
cout << " is not a whitespace." <<endl;
EXERCISES (20). Identify the following items in the programming code shown
below:
Function heading:- (void func(int speed, int time, double& distance, char& c))
Function definition:- (void func(int speed, int time, double& distance, char& c) { ... })
**************
*****************
*********************
**********************
e. Named constants.
***********************
#include <iostream>//Line 1
{ //Line 8
int t = 6; //Line 10
double d; //Line 11
cout << "d = " << d << ", ch = " << ch << endl; //Line 14
cout << "d = " << d << ", ch = " << ch << endl; //Line 16
return 0; //Line 17
} //Line 18
{ //Line 21
}
EXERCISES (26).. Write the definition of a void function that takes as input two
integer values, say n and m. The function returns the sum and average of all
the numbers between n and m (inclusive) .
#include <iostream>
if(m>n){
sum += i;
if(m<n){
sum += i;
int main() {
int n, m;
int sum;
double avg;
cout << "Sum of numbers between " << n << " and " << m << ": " << sum <<endl;
cout << "Average of numbers between " << n << " and " << m << ": " << avg <<endl;
return 0;
}
EXERCISES (29). In the following program, number the marked statements to
show the order in which they will execute (the logical order of execution).
Also what is the output if the input is 10?
#include <iostream>
int main()
num1 = 6;
cout << num1 << " " << num2 << endl;
func(num2, num1);
cout << num1 << " " << num2 << endl;
return 0;
{ int d;
d = a + b;
b = a * d;
return b;
val2 = x * y;
y = val1 + val2;
cout << val1 << " " << val2 << endl;
Output=
96
64
10 24
34 4