C Programming Exam Questions and Answers, Slides of Programming for Engineers

this is exam for Programming Fundamentals for Engineers in c languge

Typology: Slides

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
A C program contains the following declarations and initial assignments:
int i=15, j=8, k=2;
float x= 0.5 , y= -1.0, z;
char c=โ€™sโ€™, s=โ€™xโ€™;
/* character โ€˜sโ€™ is 115, and โ€˜xโ€™ is 120 */
Use the variables initially assigned to the variables for each expression to determine the
value of each the following expressions:
(8*i-2*j+21)%(2*s-c)
+j - ++y/-k;
c = = s;
('x'-'s')/(j=x=5)
i*j> โ€˜xโ€™ && โ€˜sโ€™= =115
What will be output of the following printf statements for i = 91, x = 987.4321, id=204001
1. printf("|%-4d|%3.3d|%2d |",x, x, x);
2. printf("|%.0f|%-8.3f|%6.1f |",y, y, y);
3. printf(" \"student:Nadi Lutfi\" \n \" \t :ID%d\" \n ",id);
QUESTION 2
0
"student:Nadi Lutfi"
" :ID204001"
0
0
0
987*|987*|987**
Compiler error, no โ€˜yโ€™
variable
23
pf3

Partial preview of the text

Download C Programming Exam Questions and Answers and more Slides Programming for Engineers in PDF only on Docsity!

Al-Quds University

Computer Engineering Department

1 st^ Hour Exam 2014

Student Name:______________________ SID:___________________ time:40 minutes QUESTION 1 A C program contains the following declarations and initial assignments: int i=15, j=8, k=2; float x= 0.5 , y= -1.0, z; char c=โ€™sโ€™, s=โ€™xโ€™; /* character โ€˜sโ€™ is 115, and โ€˜xโ€™ is 120 */ Use the variables initially assigned to the variables for each expression to determine the value of each the following expressions: (8i-2j+21)%(2s-c) +j - ++y/-k; c = = s; ('x'-'s')/(j=x=5) ij> โ€˜xโ€™ && โ€˜sโ€™= = What will be output of the following printf statements for i = 91, x = 987.4321, id=

1. printf("|%-4d|%3.3d|%2d |",x, x, x); 2. printf("|%.0f|%-8.3f|%6.1f |",y, y, y); 3. printf(" "student:Nadi Lutfi" \n " \t :ID%d" \n ",id); QUESTION 2

"student:Nadi Lutfi" " :ID204001"

Compiler error, no โ€˜yโ€™ variable

What will the value of i and j be after it is executed j=5; for (i=0; i<5;i++) { j++; ++i; } a) i= 11 j=5 b) i=6 j=5 c) i=5 j=8 d) i=5 j=6 e) i=6 j= What is the value of i and j after the code bellow is executed? int j=3, i=1; if(j= =1) j++; i++; ++j; printf("%d %d", j,i); a) 3 2 b) 5 2 c) 4 2 d) 3 1 e) 4 1 QUESTION 3 Answer if the following statements are True (T) or False (F)

1. #define CM PER INCH 2. 2. #define PI 3. #include <stdio.h> 3. for( ; ; ); 4. switch (num) { case 1; printf (โ€œnum is 1โ€); case 2; printf (โ€œnum is 2โ€); default; printf (โ€œnum is neither 1 nor 2โ€); }

T

T

T

F