CS Mid-Term
CS Mid-Term
Q5- Write a C++ program to print the number if the number is divided by 5
- a)16 b)20 c) 21
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;
}
3
1 برمجة:أسم المقرر جامعة صنعاء
االول:المستوى كلية الحاسوب وتكنولوجيا المعلومات
مالك الجبري. د:أستاذ المقرر ........................ : قسم
CS-PM
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 ?
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
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 ;
}
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(;;);
- }