You are on page 1of 3

CSCI01-Introduction to Computing Laboratory Midterms in C Programming Name:____________________________________________________ Score:____________________

1. Enter the following program and compile it. What does this program do? #include <stdio.h> int radius, area; Put your output here: main() { printf( "Enter radius (i.e. 10): " ); scanf( "%d", &radius ); area = (int) (3.14159 * radius * radius); printf( "\n\nArea = %d\n", area ); return 0; } Answer: _____________________________________________________________ 2. Write a program that computes a salary of a part time employee based on : - number of days worked. - number of hours per day assuming that he worked the same hours every day. - the hourly wage. Choose the right type for each variable. Write your codes here: Show your output here:

3. Write a program that reads the name and age of a person. Then, it will print a message informing him about his age after 5 years. Write down your codes here:

Computer Instructor: Maria Adeliza L. Flores (BS-IT)

CSCI01-Introduction to Computing Laboratory Midterms in C Programming 4. Enter and compile the following program. What does this program do? #include <stdio.h> Output Here: int x,y; main() { for ( x = 0; x < 10; x++, printf( "\n" ) ) for ( y = 0; y < 10; y++ ) printf( "X" ); return 0; } Answer: _______________________________________________ 5. Show the output of the C code snippet and draw a flow chart. Flowchart here: for(i = 2; i <= 6; i = i + 2) printf("%d\t", i + 1); Output: ______________________________________

6. Create a flowchart and/or tracechart for the following while loop. #include <stdio.h> int main(void) { int j; j = -5; // while loop while(j <= 0) { printf("%d ", j); j = j + 1; } return 0; } Output: _____________________________________________

Flowchart Here:

Computer Instructor: Maria Adeliza L. Flores (BS-IT)

CSCI01-Introduction to Computing Laboratory Midterms in C Programming

7. Following the Trace Chart or Flow Chart given, write a DO/WHILE Program and write down your codes and output.

Computer Instructor: Maria Adeliza L. Flores (BS-IT)

You might also like