Lab 04 - Arithmetic, Conditions and Functions

# Lab 04 - Arithmetic, Conditions and Functions - CIS*1500...

This preview shows pages 1–2. Sign up to view the full content.

CIS*1500 Computer Lab #4: Arithmetic, Conditions and Functions Duration : 40-50 minutes Objective : This week we put our newly learned concepts (arithmetic, conditional and functions) to practical use. In the first section, we fix the program presented in the classroom lab, and in the second part we incorporate custom functions into one of our programs. Part I Duration: 20 minutes In the classroom lab, we introduced the following program, and identified three bugs. /* Lab #4 – A buggy implementation of a simple calculator */ #include <stdio.h> int main(void) { int a,b,result; printf("\nThis program calculates a + b."); printf("\nEnter value for a: "); scanf("%d",&a); printf("nEnter value for b: "); scanf("%d",&b); result = a + b; printf("\na + b = %d.",result); result = a - b; printf("\na - b = %d",result); result = a * b; printf("\na * b = %d",result); result = a / b; printf("\na / b = %d",result); printf("\n"); return 0; } The bugs: The program does not print a complete description of what it does. The program allows a user to divide by 0.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 4

Lab 04 - Arithmetic, Conditions and Functions - CIS*1500...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online