Docsity

Sample Quiz 1 with Answers - Program Applied in Electronics Computer | ECE 3331, Quizzes of Electrical and Electronics Engineering

Toggle sidebar
bg1
ELEE 3331 SAMPLE QUIZ 1
I.Indicate whether each of the following is true or false by circling your choice:
A. The step that converts a C source code into object code is called
execution.
TRUE FALSE
B. All C programs must have a function named main.
TRUE FALSE
C. In an if statement, the expression to be tested must be enclosed in
parenthesis.
TRUE FALSE
D. In a for statement, the three arguments are separated by commas.
TRUE FALSE
E. All variables are initially set to zero when they are declared.
TRUE FALSE
II. Give the value of the variable on the left side of the assignment in each of
the following, assuming statements are executed sequentially and the following
statements are executed first:
int i,j,k;
float x,y,z;
i=3;
j=5;
x=4.3;
y=58.209;
k = j/i; k = 1
k = y/x; k=13
k = j%i*4; k = 8
j -= x; j = 0
z = 4.0*x-y*i/4.0+x; z = -22.15675
III. Assuming that the value of x is 11, the value of y is 6, the value of z is 1,
the value of c is 'k', and the value of d is 'y', give the value of the indicated
expression. Consider each case separately.
x ==5 || y!= 3 1
!(x>14) 1
!(x>9&&y != 23) 0
x <= 1 && y == 6 || z <4 1
c >= 'a' && c <= 'z' 1
c >= 'A' && c <= 'Z' 0
5 && y != 8 || 0 1
x >= y >= z 1
IV. Assuming that ASCII representation is used, the value of c is 'k', and the
value of d is 'y', find the value of the expression
--c == 'j' && d++ == 'y'
1
V. Convert the following algebraic expressions into equivalent c expressions:
A.
x z a
2
4
x = sqrt(fabs(z*z-4.0*a));
B.
ab c d
f
( )( )1
2
a = ((b-c)*(d+1.))/(f-2.)
pf2

Partial preview of the text

Download Sample Quiz 1 with Answers - Program Applied in Electronics Computer | ECE 3331 and more Quizzes Electrical and Electronics Engineering in PDF only on Docsity!

ELEE 3331 SAMPLE QUIZ 1

I.Indicate whether each of the following is true or false by circling your choice: A. The step that converts a C source code into object code is called execution. TRUE FALSE B. All C programs must have a function named main. TRUE FALSE C. In an if statement, the expression to be tested must be enclosed in parenthesis. TRUE FALSE D. In a for statement, the three arguments are separated by commas. TRUE FALSE E. All variables are initially set to zero when they are declared. TRUE FALSE II. Give the value of the variable on the left side of the assignment in each of the following, assuming statements are executed sequentially and the following statements are executed first: int i,j,k; float x,y,z; i=3; j=5; x=4.3; y=58.209; k = j/i; k = 1 k = y/x; k= k = j%i4; k = 8 j -= x; j = 0 z = 4.0x-yi/4.0+x; z = -22. III. Assuming that the value of x is 11, the value of y is 6, the value of z is 1, the value of c is 'k', and the value of d is 'y', give the value of the indicated expression. Consider each case separately. x ==5 || y!= 3 1 !(x>14) 1 !(x>9&&y != 23) 0 x <= 1 && y == 6 || z <4 1 c >= 'a' && c <= 'z' 1 c >= 'A' && c <= 'Z' 0 5 && y != 8 || 0 1 x >= y >= z 1 IV. Assuming that ASCII representation is used, the value of c is 'k', and the value of d is 'y', find the value of the expression --c == 'j' && d++ == 'y' 1 V. Convert the following algebraic expressions into equivalent c expressions: A. x  z 2  4 a x = sqrt(fabs(zz-4.0*a));

B. a

b c d

f

a = ((b-c)*(d+1.))/(f-2.)

VI. Write a complete C program that will input from the keyboard an amount in dollars (written without the $ but with a decimal), and output to the screen the minimum number of one dollar bills, quarters, dimes, nickels, and pennies required to make that total. Assume these are the only denominations available. main( ) { float amt; rem; int bill,quart,dim,nick,pen; printf("Please enter amount"); scanf("%f",&amt); bill = (int)amt; rem = (amt-bill)100.; quart = (int)rem/25; rem = rem-25quart; dim = (int)rem/10; rem = rem-10dim; nick = (int)rem/5; pen = rem-5nick; printf("\nNumber of bills = %d",bill); printf("\nNumber of quarters = %d",quart); printf("\nNumber of dimes = %d",dim); printf("\nNumber of nickels = %d",nick); printf("\nNumber of pennies = %d",pen); }