Week11 - ENEE 140: Introduction to Programming Concepts for...

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

View Full Document Right Arrow Icon
ENEE 140: Introduction to Programming Concepts for Engineers gangqu@umd.edu © Gang Qu Spring 2010 Week 11 No lab report due this week. Continue working on your project. Lab 19: Monday April 19 Hints on lab report 10 questions: 1. Rewrite the switch statement in the following code segment by if and if-else . int a, b; char op; scanf(“%d %d %c”, &a, &b, &op); printf(“%d %c %d: “, a, op, b); switch (op) { case ‘+’: printf(“%d\n”, a+b); break; case ‘-‘: printf(“%d\n”, a-b); break; case ‘*’: printf(“%d\n”, a*b); break; case ‘/’: if (b!=0) p r i n t f ( % d \ n , a / b ) ; else p r i n t f ( C a n n o t / b y 0 . \ n ) ; default: printf(“Not a valid operation.\n”); } What you will learn from these questions is how to create representative test i n p u t s t o c h e c k w h e t h e r y o u r p r o g r a m w o r k s a s d e s i red in all scenario You need at least one input each to test the cases of +, -, and *, respectively. For /, you need to have two inputs, one with b != 0 and one with b = 0. Note that inputs
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 2

Week11 - ENEE 140: Introduction to Programming Concepts for...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online