0% found this document useful (0 votes)
76 views7 pages

CS Mid-Term

Uploaded by

momkm61
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)
76 views7 pages

CS Mid-Term

Uploaded by

momkm61
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

1 ‫ برمجة‬:‫أسم المقرر‬ ‫جامعة صنعاء‬

‫ االول‬:‫المستوى‬ ‫كلية الحاسوب وتكنولوجيا المعلومات‬


‫ مالك الجبري‬.‫ د‬:‫أستاذ المقرر‬ ........................ : ‫قسم‬
CS-AM

Mid-term Examination (Questions Sheet)


Part One: Direct Questions:
‫م م‬2020-2019 :‫الفصل الدراسي‬
Q1- Display the message "Enter two numbers".
Q2- Write a C++ program that reads an integer and determines and prints
whether it is odd or even.
Q3- Write C++ Program to Find Sum and Average of three numbers?
Q4- Write a C++ program That calculates the rate of student the program will
read 6 scores and determine the rate:
Note:

Q5- Write a C++ program to print the number if the number is divided by 5

Part Two: The MCQ Questions :


Q1- The ……… represents the newline character, which causes the cursor to
position to the beginning of the next line on the screen.
a) \n b) \t c) \ a
Q2-
d) The value of x after this statement x = 4- 8 /4 *2; is performed equal 0 ( )
The object used to print information on the screen in C++ program is:
a) cin b) cout c) none
Q3- What will be the value of integer variable x after the following statement is
performed
x = 8+ 3 * 7 / 3;
a) 15 b) 25 c) 14

Part Three: The True/False Questions :


Q1. Comments cause the computer to print the text enclosed between /* and */ on
the screen when the program is executed ( ).
Q2. The escape sequence \n, when output with cout and the stream insertion
operator, causes the cursor to position to the beginning of the next line on the
screen ( ) .
Q3. ( ) - All variables must be defined before they’re used.
Q4. ( ) - Definitions can appear anywhere in the body of a function.
Q5. The assembly languages represent the only way to communicate directly with
the computer. ( ).
1
1 ‫ برمجة‬:‫أسم المقرر‬ ‫جامعة صنعاء‬
‫ االول‬:‫المستوى‬ ‫كلية الحاسوب وتكنولوجيا المعلومات‬
‫ مالك الجبري‬.‫ د‬:‫أستاذ المقرر‬ ........................ : ‫قسم‬
CS-AM

Part four: 3. Write the output of programs? ( 2 Mark each


Question) :
Q1- ‫م م‬2020-2019 :‫الفصل الدراسي‬
int main()
{ int a;
a = 5 + 3 * 5;
cout << ++a;
return 0;
}
- a) 20 b) 21 c) 41
Q2-
#include<iostream.h>
main()
{
Int x=5, y=4, n;
n=++x + x++;
cout<<”n=”<<++n<<”\t”<<”x=”<< x++<<endl;
n= x++ * ++ y;
- cout<<”n=”<<n++<<”\t”<<”x=”<< ++x<<”\ty=”<<y++<<endl;}
Q3-
int main()
{
int n = 4;
cout << ++n + 6 * n++ / 2;
}

- a)16 b)20 c) 21

Part five: Correct the following programs :


Q1-
int main[ ]
{
int Number;
cout<<”enter number:”
cin>>number;
return 0;
}

2
1 ‫ برمجة‬:‫أسم المقرر‬ ‫جامعة صنعاء‬
‫ االول‬:‫المستوى‬ ‫كلية الحاسوب وتكنولوجيا المعلومات‬
‫ مالك الجبري‬.‫ د‬:‫أستاذ المقرر‬ ........................ : ‫قسم‬
CS-AM

Q2-
int main( )
{
‫م م‬i==1,i>100;i++)
for( 2020-2019 :‫الفصل الدراسي‬
cout>>i>>”\t”;
return 0;
}
Q3-
#include<iostream>
Using namespace std;
int main ( )
{
int first_number,
cout<<”enter number:”;
cin<<first_number ;
cout<<the number is <<first_number<<\n;
return 0;
}

Lecturer Name: Signature:

3
1 ‫ برمجة‬:‫أسم المقرر‬ ‫جامعة صنعاء‬
‫ االول‬:‫المستوى‬ ‫كلية الحاسوب وتكنولوجيا المعلومات‬
‫ مالك الجبري‬.‫ د‬:‫أستاذ المقرر‬ ........................ : ‫قسم‬
CS-PM

Mid-term Examination (Questions Sheet)


Part One: Direct
‫م م‬2020 Questions
-2019 :‫اسي‬ ‫ الفصل الدر‬:

Q1- Write a C++ program that reads an integer and determines and prints
whether it is odd or even.

Q2- Write a program that computes the value of nx by using the Factorial
formula n! = n · (n – 1) · (n – 2) · … · 1 (for values of n greater than 1)
Q3- Create the logical expression for all statements below using (if statement):
The variable age is positive number and less than 30:
--------------------------------------------------------------------------------------------------
-----.
The choice value is Y or N
--------------------------------------------------------------------------------------------------
-----.
Print stop when the value of count =-1
--------------------------------------------------------------------------------------------------
-----.
The value of x equal to A or a and salary less than 300
--------------------------------------------------------------------------------------------------
---.
Q4- Write a program print square numbers from 1-20 using while statements?
20 -1 ‫اكتب برنامج يطبع مربع اإلعداد من‬

Q5- Write a C++ program that reads 3 integers and then determines and prints
the largest ?

Part Two: The MCQ Questions :

Q1-
What will be the value of integer variable x after the following statement is performed
x = 8+ 3 * 7 / 3;
a) 15 b) 25 c) 14
Q2- Which of the following is the correct syntax to print the message in C++ language?
a) cout <<"Hello world!";
b) Cout << Hello world! ;
c) Out <<"Hello world!;
d) None of the above
Q3-What is the output of this program?
int main()
1
1 ‫ برمجة‬:‫أسم المقرر‬ ‫جامعة صنعاء‬
‫ االول‬:‫المستوى‬ ‫كلية الحاسوب وتكنولوجيا المعلومات‬
‫ مالك الجبري‬.‫ د‬:‫أستاذ المقرر‬ ........................ : ‫قسم‬
CS-PM

{
/* this is comment*
‫ م‬cout
‫م‬2020<<
-2019"hello world";
:‫الدراسي‬ ‫الفصل‬
return 0;
}
a) hello world b) compile time error c) none of the mentioned
Q4-What is the output of this program?
int main()
{ int a;
a = 5 + 3 * 5;
cout << ++a;
return 0;
}
a) 20 b) 21 c) 41
Q5-What will the following loop display?
int main()
{
int n = 4;
cout << ++n + 6 * n++ / 2;
}
a)16 b)20 c) 21

Part Three: The True/False Questions :


Q1. ( ) Every C++ program begins execution at the function main.
Q2. ( ) Comments cause the computer to print the text enclosed between /* and */ on
the screen when the program is executed.
Q3. ( ) All variables must be defined before they’re used.
Q4. ( ) High-level languages are a vast improvement over machine and assembly
languages because they allow the programmer to use instructions that more closely
resemble the English language.
Q5. ( ) When writing a procedure-oriented program, the programmer concentrates on
the major tasks that the program needs to perform.

Part four: 3. Write the output of programs? :


Q1-
#include<iostream.h>
int main()
{
int x=1,y=2;
y++;
++x;
2
1 ‫ برمجة‬:‫أسم المقرر‬ ‫جامعة صنعاء‬
‫ االول‬:‫المستوى‬ ‫كلية الحاسوب وتكنولوجيا المعلومات‬
‫ مالك الجبري‬.‫ د‬:‫أستاذ المقرر‬ ........................ : ‫قسم‬
CS-PM

cout<<x++<<endl<<++y;
x=2* 7 + ++x + y--;
cout<<x<<endl<<y;
‫م م‬2020-2019 :‫الفصل الدراسي‬
return 0;
}
Q2-
#include <iostream.h>
using namespace std;

void main()
{
int x=3;
int y=5;
x = x*y;
y = x/y;
x = x/y+10;
cout <<"x ="<< x<< "y = " <<y;
}
Q3-
#include <iostream.h>
using namespace std;

Void main ()
{
int x =0 ; y;
y =x+5;
x=y;
cout << "y =" << y << endl;
cout << "x = "<< x ;
}

Part five: Correct the following programs :


Q1-
#include <iostream>
using namespace std;
int main()
{
int a=0;
cout << "Enter The Number:\t";
cin >> a;
if (a%2==0)
cout << "\nThe Number is divide by 2\n"
3
1 ‫ برمجة‬:‫أسم المقرر‬ ‫جامعة صنعاء‬
‫ االول‬:‫المستوى‬ ‫كلية الحاسوب وتكنولوجيا المعلومات‬
‫ مالك الجبري‬.‫ د‬:‫أستاذ المقرر‬ ........................ : ‫قسم‬
CS-PM

return 0;
}
Q2- ‫م م‬2020-2019 :‫الفصل الدراسي‬
#include <iostream>
using namespace std;
int main()
{
int i=0 ,j=0;
cin >> i >> j ;
if (i > j ) {
cout << "The number i is bigger than j" ;
}
return 0;
}
Q3-
#include<iostream.h>
main()
{int x,y,z;
x=5;
y=6;
z=x+y;
cout<<"the sum number : z= "<<z;
for(;;);
- }

Lecturer Name: Signature:

You might also like