Mid Exam 1213
Page 1 of 4
Computer Programming 1
College Of Science and Technology
Khan younis - Palestine
Computer Science & Inf. Tech.
Computer Programming 1
Time: 100 Minutes
28.11.2012
PC ID
ID:
30
Mark:
Teacher
Mahmoud Rafeek Alfarra
First Question
Branch 1
(9/30)
(15 min.)
(4/9)
State whether each of the following is true[T]or false [F].If false, why[you
have one of them as bonus]?
1
An algorithm is a procedure for solving a problem in terms of
unordered actions.
2
In high-level language, translator programs called compilers which
convert programs into machine language.
3
Many pseudo codes can be represented by Flow chart but not all of
them.
4
In sequential structure the statements in a program are executed one
after the other in the order in which they are written.
5
Programming languages may be divided into two general types.
6
In Java, Classes include pieces called files that perform tasks and
return information when they complete them.
7
All data types in Java are primitive data types.
8
Reversing the operators !=, >= and <=, as in =!, => and =<, is a logical
error.
9
The Sum#id is a legal identifier.
Mid Exam 1213
Page 2 of 4
Computer Programming 1
PC ID
Branch 2
(20 min.)
(5/9)
Write a Java statement or a set of Java statements to accomplish each of the
following tasks:
1
Assign the sum of x and y to z, and then print sum
2
Declare a boolean variable (flag) which has (true) value as a default.
3
Print the following statement:
My name is\ Mahmoud "Rafeek" AlFarra
4
Check if the value of integer x greater than 5 or less than 0
5
y= 2x +3z2-xz
Second Question
(5/30)
(20 min.)
(5/5)
Identify and correct the errors in each of the following pieces of code (to each
error you must note its type, where it is, how to correct):
Note that: each pies may contain many errors
int a=6;
1
If(a>10);
System.out.println( a );
int id = 123;
2
System.out.println("My Id is: + " id );
Mid Exam 1213
Page 3 of 4
Computer Programming 1
PC ID
int 1x =5; int 2x = 7;
3
if (1x>3 && 2x >=5);
System.out.println("Thanks ");
String name ="Ali";
If (name == "Ali")
4
System.out.println("Salamo Aliko");
else
System.out.println("try again");
5
float b = 2.3;
double c= 4.5;
if (b>0)
if (c>2)
JOptionPane.showMessageDialoge("welcome");
Third Question
Branch 1
(30 min.)
A] Write the algorithms for the following cases:
(16/30)
(10/16)
1
Draw a flowchart to develop a program which receive many positive integer
numbers from user and print the odd and even numbers, the receiving will
be stopped if the number less than 0.
2
Write a pseudo code to accept 2 integers from the user and print the
maximum and minimum one.
3
Write an algorithm to calculate how many IT student successes in the
Programming 1 course.
4
The factorial of a nonnegative integer n is written as n!, And is defined as
follows: n! = n*(n-1)*(n-2)*(n-3)* ….. 1
Write an algorithm that reads a nonnegative integer and prints its factorial.
Branch 2
(15 min.)
B] Solve each of the following as required:
1. Explain the deference between input unit and input device.
(6/10)
Mid Exam 1213
Computer Programming 1
Page 4 of 4
2. Explain, how to calculate the following equation?
PC ID
Y = 2 – 3 * 7 % 8 / ((1 + 5) - 1)
3. After the program is written by programmer, the computer performs
many tasks on it, explain by drawing.
(10 min.)
Bonus Question
Trace the following program:
int x =1;
if (x > 10)
System.out.print( "****\n***\n**\n*" );
else if (x> 5)
System.out.print( "**\n*" );
else
{
System.out.print( "***\n **\n *" );
System.out.print( "Thanks" );
}
System.out.println("Good Time");
With My best Wishes
Mahmoud Rafeek Alfarra
(3/0)
© Copyright 2026 Paperzz