Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSCE 206 Lab Structured Programming in C

Similar presentations


Presentation on theme: "CSCE 206 Lab Structured Programming in C"— Presentation transcript:

1 CSCE 206 Lab Structured Programming in C
Spring 2019 DEBUG

2 Ideas on how to debug Go line by line IN ORDER from the start of the program and think what each line DOES Put printf() after each statement where you modify something You can start from the ones that you doubt Also to calculate partial results if you have large formulas Calculate by hand the partial results to compare Create other inputs to find corner cases Create another set of inputs and calculate by hand what the total should be Check that it also produces a good output

3 Debugging code #include <stdio.h> int main(void) { int a, b;
float c, d, total; printf("Enter 4 numbers:"); scanf("%d %d %f %f",&a, &b, &c, &d); total = (((c*d)-a)/b)+(c*d)-(b*a/b); printf(”The total is:%f\n", total); return 0; }


Download ppt "CSCE 206 Lab Structured Programming in C"

Similar presentations


Ads by Google