chap05_notes

chap05_notes - Chapter 5 notes Force.c if(t <= 3) p = 20.0;...

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

View Full Document Right Arrow Icon
Chapter 5 notes Force.c if(t <= 3) p = 20.0; else p = 4*(t+2); // simplified formula Force2.c if(0 <= t && t <= 3){ p = 20.0; printf("Force p = %f\n", p); } else if (t>3){ p = 4*(t+2); printf("Force p = %f\n", p); } else printf(“Invalid input \ n”); Ifgrade.c if(grade == 'A') /* entered A */ score = 4.0; else if(grade == 'B') /* entered B */ score = 3.0; else if(grade == 'C') /* entered C */ score = 2.0; else if(grade == 'D') /* entered D */ score = 1.0; else if(grade == 'F') /* entered F */ score = 0.0; /* entered any other character */ else { score = -1; printf("Invalid grade '%c'\n", grade); } if(score != -1) printf("The score for the grade '%c' is %.2f\n", grade, score); Switchgrade.c switch(grade) { case 'A': /* entered A */ score = 4.0; break; case 'B': /* entered B */ score = 3.0; break; case 'C': /* entered C */ score = 2.0; break; case 'D': /* entered D */ score = 1.0; break; case 'F': /* entered F */ score = 0.0; break; default: /* entered any other character */ score = -1;
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.

This document was uploaded on 08/23/2010.

Page1 / 2

chap05_notes - Chapter 5 notes Force.c if(t <= 3) p = 20.0;...

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