Med Term 2024
Med Term 2024
By
Mohamed Mahamoud
بسم اهلل الرمحن الرحيم
َ ع ۡقدَ ٗة من ل
ساني يَ ۡفقَ ُهواْ قَ ۡولي ۡ ي أ َ ۡمري َو
ُ ٱحلُ ۡل ٓ ص ۡدري َويَس ۡر ل ۡ َرب
َ ٱش َر ۡح لي
صدق هللا العظيم
اللهم علمنا ما ينفعنا وانفعنا مبا علمتنا وزدنا بك علما انك انت العليم احلكيم
1) Which statement will read an entire line of input into the following string object
string address;
A) cin << address; B) cin address:
C) getline(cin, address); D) cin.get(address);
2) This stream manipulator forces cout to print the digits in fixed- point notation.
A) setprecision(2) B) serw (2) C) fixed D) setfixed(2)
4) In a nested loop, the………..loop goes through all its iterations for every single
iteration of the …….loop
A) near/far B) far/near C) inner/outer D) outer/inner
5) The causes a program to wait until information is typed at the keyboard and the
Enter key is pressed
A) Output stream B) cin object C) cout object D) Preprocessor
6) reads a line of input, including leading and embedded spaces, and stores it in a
stang object
A) cin get B) getline C) cin getline D) get
8) When a variable is assigned a number that is too large for us data type, it
A) underflows
B) overflows
C) reverses polarity
D) exceeds expectations
Q2. (10 marks) What is the output of the following code fragments? You must
write the exact output as if the computer prints it. If it is any type of error, write
the type of error (for example, run time error).
Q3. (3 marks) Write a piece of C++ program that accept a positive number in a
range and outputs
pattern:
Input an Integer number (less than 10): 4 [Enter]
16 16 16 16
999
44
ولو هتعمله هرم هيكون كده
Q4. (3 marks) Write a C ++ function distance that calculates the distance between
two points ( x1,y1) and ( x2,y2). All numbers and return values should be of type
double. If the second point is not given, the function calculates the distance to the
origin.
Q5. (5 marks) Write a complete C++ program and a function that calculates the
roots of the quadratic equation by implementing a suitable function. The function
must check if the roots are real or complex numbers. You must use pass by
reference to return the roots from the function. To return the Type of the roots, you
can use bool or string return value, or pass by reference. Show how to use this
function in the main() function using good formatted output
عشان تجيب حلول المعادلة التربيعية هنستخدم القانون العام
−𝑏 ± √𝑏 2 − 4𝑎𝑐
2𝑎
يكون للمعادلة حلول تخيلية وان اكبر هات الحلول من0 𝑏 اقل من2 − 4𝑎𝑐 واذا كان
القانون اللي فوق