You are on page 1of 3

Dr. Tolga Soyata. U of R, Electrical and Computer Engineering, tolga.soyata@rochester.

edu


ECE114 Exam0 Exam Period : 2PM - 3:15PM

Submission Period : 3:10PM - 3:15PM. No exceptions SUBMIT THROUGH BLACKBOARD

You are required to submit your program(s) within the five minutes after the
exam through Blackboard. You may not work on your programs after 3:10PM.
Your submission will be time stamped by Blackboard. Any submission after the
allowed period will be graded as zero.

In this exam, you will be required to write two programs within 70 minutes. You are not allowed to text
anyone, talk to anyone, call anyone, or access the internet during the exam. You can use the
calculator in Windows (calc.exe).

Your computers will be unplugged from the internet during the exam and plugged back in at the end
of the exam. Once you are back on the internet after the exam, you will have 5 minutes to submit your
code through Blackboard.

ECE114 Exam0 10 points


MINI CHEAT SHEET:

Example for() loop syntax: Example do{} loop syntax: Example while() loop syntax:

for (a=0; a<10; a++){ do{ while(t<45){

} } while(a>5); }



Example scanf() syntax for user input: scanf("%lf",&f) // use %lf for double
scanf("%f",&f) // use %f for float
scanf("%d",&x) // use %d for int






Dr. Tolga Soyata. U of R, Electrical and Computer Engineering, tolga.soyata@rochester.edu


Program 1 (5 points): listnum.c

Write a program that displays numbers from -10 to +9, their squares, and square roots in a nicely
formatted fashion. If the number is negative, it should write Complex in the square root column. You
have to use a for() loop, while() loop, or a do{} loop. Any one of these is acceptable.

Program 1 grading tips: Nice formatting is 1 point, functionality is 3 points, careful casting and
technical quality as well as careful bracketing the statements is 1 point. Using a bunch of printf()
statements to create this output will get you zero points !!! You have to do it with a loop !!!


Program 1 Expected Output:







Dr. Tolga Soyata. U of R, Electrical and Computer Engineering, tolga.soyata@rochester.edu


Program 2 (5 points): calcnum.c

Write a program that gets an int type (i.e., signed integer) number from the user and displays a few
pieces of information about that number : a) whether it is divisible by 3 or not, b) whether it is odd or
even, c) whether it is a negative or positive number, d) its square root only if the number is positive,
otherwise display Square root is complex . Keep getting the number from the user until (s)he enters
0. Then, finish the program and display Thanks Bye.
To ask the user to enter numbers, display a message like
Please enter a number. Enter zero to stop.

Program 2 grading tips: Careful casting and technical quality as well as careful bracketing the
statements is 1 point. Functionality is 4 points.

Program 2 Expected Output:

You might also like