CSCE 206 Lab Structured Programming in C

Slides:



Advertisements
Similar presentations
Lab 8 User Defined Function.
Advertisements

Exercise 4 1. Write a program that simulates coin tossing. For each toss of the coin the program should print Heads or Tails. Let the program toss the.
Software Development Method. Assignments Due – Homework 0, Warmup Reading – Chapter 2 –
Guidelines for working with Microsoft Visual Studio.Net.
Declarations/Data Types/Statements. Assignments Due – Homework 1 Reading – Chapter 2 – Lab 1 – due Monday.
Guidelines for working with Microsoft Visual Studio 6.
For Loop Lesson 3 CS1313 Spring for Loop Lesson 3 Outline 1. for Loop Lesson 3 Outline 2. for Loop with a float Counter: BAD! 3. float Counter Example.
Functions in C. Function Terminology Identifier scope Function declaration, definition, and use Parameters and arguments Parameter order, number, and.
CS140: Intro to CS An Overview of Programming in C by Erin Chambers.
History of C 1950 – FORTRAN (Formula Translator) 1959 – COBOL (Common Business Oriented Language) 1971 – Pascal Between Ada.
Principles of Programming - NI Simple Recursion Recursion is where a function calls itself. Concept of recursive function: A recursive function is.
Computer Programming for Engineers. Outline Tic-Tac-Toe (O-X Game) Drawing 3x3 grid Receiving the inputs Checking for a winner Taking turns between.
WEEK 4 Class Activities Lecturer’s slides.
How to start Visual Studio 2008 or 2010 (command-line program)
A First C Program /* Print a Message */ #include main() { printf("This is a test!\n"); } The program is compiled and run as cc pg32.c  a.out  This is.
CS140: Intro to CS An Overview of Programming in C (part 3) by Erin Chambers.
CS140: Intro to CS An Overview of Programming in C by Erin Chambers.
How to design and code functions Chapter 4 (ctd).
Problems Reads a letter grade from user and displays the corresponding range for that letter grade (A  , B  80-89, C  70-79, D  60-69, otherwise.
Principles of Programming - NI Simple Recursion Recursion is where a function calls itself. Concept of recursive function: A recursive function is.
CSCI 171 Presentation 3. Operators Instructs C to perform some operation Assignment = Mathematical Relational Logical.
1 TOPICS TO DISCUSS : FUNCTIONS TYPES OF FUNCTIONS HEADER FILES PRESENTED BY : AVISHEK MAJUMDAR(837837) GUNJAN AGARWAL(856587) SATYAPRIYA DEY(856624)
Some remarks before we get started… Last time we learned about header files – in particular the math.h header file. You know that if you include math.h.
NOTE: C programs consist of functions one of which must be main. C programs consist of functions one of which must be main. Every C program begins executing.
Lecture2.
Introduction to Computer Algorithmics and Programming Ceng 113
Zhang Hongyi CSCI2100B Data Structures Tutorial 3
Formatted Input/Output
INC 161 , CPE 100 Computer Programming
Chapter 4 (Conditional Statements)
CS1010 Programming Methodology
Functions in C Mrs. Chitra M. Gaikwad.
Formatted Input/Output
2008/11/10: Lecture 16 CMSC 104, Section 0101 John Y. Park
מבוא כללי למדעי המחשב תרגול 2
Control Structures Lecture 7.
Compiled and ready to run Memory Stack /*
The while Looping Structure
2008/10/27: Lecture 13 CMSC 104, Section 0101 John Y. Park
Arrays & pointers C How to Program, 8/e.
INC 161 , CPE 100 Computer Programming
Lec 7.
مفاهیم بهره وري.
Program Control Structures
CSCE 206 Lab Structured Programming in C
CSCE 206 Lab Structured Programming in C
Functions, Part 2 of 3 Topics Functions That Return a Value
for Loop Lesson 3 Outline
The while Looping Structure
Conditionals.
Lecture3.
2008/10/27: Lecture 13 CMSC 104, Section 0101 John Y. Park
Solutions to In-Class Problems
Assignment Operators Topics Increment and Decrement Operators
Introduction to Computer Organization & Systems
EECE.2160 ECE Application Programming
Introduction to Computer Organization & Systems
More Loops Topics Counter-Controlled (Definite) Repetition
Character Arrays char string1[] = “first”;
Assignment Operators Topics Increment and Decrement Operators
Assignment Operators Topics Increment and Decrement Operators
CSCE 206 Lab Structured Programming in C
The while Looping Structure
CSCE 206 Lab Structured Programming in C
CSCE 206 Lab Structured Programming in C
CSCE 206 Lab Structured Programming in C
Functions, Part 2 of 3 Topics Functions That Return a Value
The while Looping Structure
Functions, Part 2 of 3 Topics Functions That Return a Value
Assignment Operators Topics Increment and Decrement Operators
Presentation transcript:

CSCE 206 Lab Structured Programming in C Spring 2019 DEBUG

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

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; }