Computer Engineering Exam: 1st Hour Exam 2014, Exams of Programming for Engineers

this is exam for Programming Fundamentals for Engineers in c languge

Typology: Exams

2021/2022

Uploaded on 05/18/2023

khader-qaabar-1
khader-qaabar-1 🇵🇸

5 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Al-Quds University
Computer Engineering Department
1st Hour Exam 2014
Student Name:______________________ SID:___________________ Time:40 minutes
QUESTION 1 (10 MARKS)
Circle the right answer.
1.1 Referring to the sample code bellow, what is the new content of the "x" array?
a) { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 } b) { 0, 1, 20, 3, 4, 5, 6, 7, 8, 9 }
c) { 0, 1, 2, 20, 4, 5, 6, 7, 8, 9 } d) { 0, 1, 2, 3, 20, 5, 6, 7, 8, 9 }
e) { 0, 1, 2, 3, 4, 20, 6, 7, 8, 9 }
1.2 In the following code segment, what is the value of i?
int i;
i = sizeof("\007");
a) 1 b) 2 c) 3 d) 4 e) 5 f) 6
1.3 What happens when the program below is compiled and executed?
a) The code prints out: j=3. b) It does not compile c) The address of "j" is printed out.
d) The code prints out: j=2. e) The code prints out: j=4.
1.4 In What is the value of "x" in the sample code below?
double x;
x = 3 + 5 * 2 + 2;
a) 12 b) 15 c) 18 d) 23 e) 32
1.5 What value does x[3] in the sample code below contain?
int x[5] = {1,2,3,4,5}
a) 1 b) 2 c) 3 d) 4 e) 5
pf3

Partial preview of the text

Download Computer Engineering Exam: 1st Hour Exam 2014 and more Exams Programming for Engineers in PDF only on Docsity!

Al-Quds University

Computer Engineering Department

st

Hour Exam 2014

Student Name:______________________ SID:___________________ Time:40 minutes QUESTION 1 (10 MARKS) Circle the right answer. 1.1 Referring to the sample code bellow, what is the new content of the "x" array? a) { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 } b) { 0, 1, 20, 3, 4, 5, 6, 7, 8, 9 } c) { 0, 1, 2, 20, 4, 5, 6, 7, 8, 9 } d) { 0, 1, 2, 3, 20, 5, 6, 7, 8, 9 } e) { 0, 1, 2, 3, 4, 20, 6, 7, 8, 9 } 1.2 In the following code segment, what is the value of i? int i; i = sizeof("\007"); a) 1 b) 2 c) 3 d) 4 e) 5 f) 6 1.3 What happens when the program below is compiled and executed? a) The code prints out: j=3. b) It does not compile c) The address of "j" is printed out. d) The code prints out: j=2. e) The code prints out: j=4. 1.4 In What is the value of "x" in the sample code below? double x; x = 3 + 5 * 2 + 2; a) 12 b) 15 c) 18 d) 23 e) 32 1.5 What value does x[3] in the sample code below contain? int x[5] = {1,2,3,4,5} a) 1 b) 2 c) 3 d) 4 e) 5

QUESTION 2 (4 MARKS)

Given the function below, find and correct the syntax errors int afunction ( int a, int b) { float c , sum; int n, a[10]; for (n= =0; n<=10; n++) if (n mod 3) printf ("%d", a[n]); sum=sum + a[n]; return sum; } main() { int sum; afunction (5,5) printf ("%s \n", sum); return sum; } QUESTION 3 (6 MARKS) Show the output generated by each of the following C programs? #include <stdio.h> main ( ) { int a, b = 0; static int c[10]={1,2,3,4,5,6,7,8,9,0}; for (a = 0; a < 10; ++a) if ((c [a] % 2) == 0 )b += c[a]; printf ("%d", b); } #include <stdio.h> main ( ) { int a, b = 0; static int c[10]={1,2,3,4,5,6,7,8,9,0}; for (a = 0; a < 10; ++a) if ((a % 2) == 0 )b += c[a]; printf ("%d", b); } #include <stdio.h> #define ROWS 3 #define COLUMNS 4 int z [ROWS][ COLUMNS] = {1,2,3,4,5,6,7,8,9,10,11,12}; main() { int a,b,c,= 999; for (a = 0; a < ROWS; ++a) #include <stdio.h> #define ROWS 3 #define COLUMNS 4 int z [ROWS][ COLUMNS] = {1,2,3,4,5,6,7,8,9,10,11,12}; main() { int a,b,c; for (a = 0; a < ROWS; ++a) {