Compiled and ready to run Memory Stack /*

Slides:



Advertisements
Similar presentations
TDBA66, VT-03 Lecture - Ch. 21 A complete C-program Display Fig. 2.1 and comment on different things such as Preprocessor directives Header files Identifiers.
Advertisements

1 CS 201 Introduction to C (1) Debzani Deb. 2 Outline Overview of C General form of a C program C Language Elements.
1 ICS103 Programming in C Lecture 8: Data Files. 2 Outline Why data files? Declaring FILE pointer variables Opening data files for input/output Scanning.
1 ICS103 Programming in C Lecture 3: Introduction to C (2)
Software Development Method. Assignments Due – Homework 0, Warmup Reading – Chapter 2 –
Topic 2 – Introduction to the C Programming Language.
1 CS 201 Introduction to C (2) Debzani Deb. 2 Overview C Arithmetic Expressions Formatting Numbers in Program Output Interactive Mode, Batch Mode, and.
1 ICS103 Programming in C Lecture 2: Introduction to C (1)
CISC 105 – Topic 2 Last Topic Review Name the principle components of a computer. What advantage does assembly language have over machine language? What.
Functions in C. Function Terminology Identifier scope Function declaration, definition, and use Parameters and arguments Parameter order, number, and.
Chapter 2 : Overview of C By Suraya Alias. /*The classic HelloWorld */ #include int main(void) { printf(“Hello World!!"); return 0; }
Problem Solving and Program Design in C (5th Edition) by Jeri R. Hanly and Elliot B. Koffman CPCS 202 Chapter 2 – Input/Output
CISC105 General Computer Science Class 1 – 6/5/2006.
Chapter 2 Overview of C Part I J. H. Wang ( 王正豪 ), Ph. D. Assistant Professor Dept. Computer Science and Information Engineering National Taipei University.
 Input and Output Functions Input and Output Functions  OperatorsOperators Arithmetic Operators Assignment Operators Relational Operators Logical Operators.
Pengantar C/C++. 2 Outline  C overview  C language elements  Variable declarations and data types  Executable statements  General form of a C program.
Overview of C Programming Language
#include int main(void) { printf("Hello, world!\n"); return 0; } entry point called on program start only one main( ) in any program # for preprocessor.
1 C Programming Week 2 Variables, flow control and the Debugger.
ELE118 Introduction to Programming
CS1010E Programming Methodology. POH YEE HUI Electrical Engineering Year 3
Khalid Rasheed Shaikh Computer Programming Theory 1.
Functions: Part 2 of /11/10: Lecture 16 CMSC 104, Section 0101 John Y. Park 1.
E-1 University of Washington Computer Programming I Lecture 5: Input and Output (I/O) © 2000 UW CSE.
9/29/99B-1 CSE / ENGR 142 Programming I Variables, Values, and Types © 1998 UW CSE.
1 ELE118 lecture 3 Dr. Mehmet Demirer Dr. Seniha Esen Yuksel.
Program Development Cycle 1.Edit program 2.Compile program - translates it from C to machine language 3. Run/execute your program. 4. If not satisfied,
A.Abhari CPS1251 Topic 2: C Overview C Language Elements Variable Declaration and Data Types Statement Execution C Program Layout Formatting Output Interactive.
ZyBooks /12/16. Exam I 2/19/16 Review next week.
1 C Syntax and Semantics Dr. Sherif Mohamed Tawfik Lecture Two.
1 ICS103 Programming in C Lecture 7: Repetition Structures.
C Language Elements Preprocessor Directives # (sign for preprocessor directive commands) #include Standard header file (.h) Library.
Introduction to C Week Parts of a C Program.
© Copyright by Deitel 1 Chapter 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line of Text 2.3Another Simple.
CHAPTER 4 REPETITION STRUCTURES 1 st semester King Saud University College of Applied studies and Community Service Csc 1101 A.AlOsaimi.
Lecture2.
CS1010 Programming Methodology
Prepared By: Pn. Nik Maria Nik Mahamood (Coordinator DDC 1012)
CS1001 Programing Fundamental Lecture 5 Top-Down Design with Functions
Week 4 Introduction to C.
Zhang Hongyi CSCI2100B Data Structures Tutorial 3
Input and Output: I/O Finish reading chapters 1 and 2 of the text
Functions, Part 2 of 2 Topics Functions That Return a Value
What's a Computer? Monitor Disk Main mouse Memory Keyboard Network
Chapter 2 Overview of C.
ICS103 Programming in C Lecture 3: Introduction to C (2)
Exercises on String Operations
Lecture2.
2008/11/10: Lecture 16 CMSC 104, Section 0101 John Y. Park
Chapter 2 Overview of C.
#include <stdio.h> int main(void) { printf("Hello, world!\n");
CC213 Programming Applications
Introduction to CS Your First C Programs
Functions Chapter 3 of the text Motivation:
CSCE 206 Lab Structured Programming in C
Functions, Part 2 of 3 Topics Functions That Return a Value
Overview of Computers and C Programming
#include <stdio.h> int main(void) { printf("Hello, world!\n");
Lecture3.
Chapter 2: Overview of C Problem Solving and Program Design in C 5th Edition by Jeri R. Hanly and Elliot B. Koffman.
Character Arrays char string1[] = “first”;
Data Type.
CSCE 206 Lab Structured Programming in C
How Memory Leaks Work with Memory Diagram
CSCE 206 Lab Structured Programming in C
Functions, Part 2 of 3 Topics Functions That Return a Value
Functions, Part 2 of 3 Topics Functions That Return a Value
Computer Science II CS132/601* Lecture #C-1.
Miles to Kilometers problem
Presentation transcript:

Compiled and ready to run Memory Stack /* * Converts distance in miles to kilometers. */ #include <stdio.h> /* printf, scanf definitions */ #define KMS_PER_MILE 1.609 /* conversion constant*/ int main(void) { double miles, /* input - distance in miles. */ kms; /* output - distance in kilometers */ /* Get the distance in miles. */ printf("Enter the distance in miles> "); scanf("%lf", &miles); /* Convert the distance to kilometers. */ kms = KMS_PER_MILE * miles; /* Display the distance in kilometers. */ printf("That equals %f kilometers.\n", kms); return (0); } Memory Stack Compiled and ready to run

→ Memory Stack /* * Converts distance in miles to kilometers. */ #include <stdio.h> /* printf, scanf definitions */ #define KMS_PER_MILE 1.609 /* conversion constant*/ int main(void) { double miles, /* input - distance in miles. */ kms; /* output - distance in kilometers */ /* Get the distance in miles. */ printf("Enter the distance in miles> "); scanf("%lf", &miles); /* Convert the distance to kilometers. */ kms = KMS_PER_MILE * miles; /* Display the distance in kilometers. */ printf("That equals %f kilometers.\n", kms); return (0); } Memory Stack

→ Memory Stack /* * Converts distance in miles to kilometers. */ #include <stdio.h> /* printf, scanf definitions */ #define KMS_PER_MILE 1.609 /* conversion constant*/ int main(void) { double miles, /* input - distance in miles. */ kms; /* output - distance in kilometers */ /* Get the distance in miles. */ printf("Enter the distance in miles> "); scanf("%lf", &miles); /* Convert the distance to kilometers. */ kms = KMS_PER_MILE * miles; /* Display the distance in kilometers. */ printf("That equals %f kilometers.\n", kms); return (0); } Memory Stack →

→ Memory Stack 1.609 /* * Converts distance in miles to kilometers. */ #include <stdio.h> /* printf, scanf definitions */ #define KMS_PER_MILE 1.609 /* conversion constant*/ int main(void) { double miles, /* input - distance in miles. */ kms; /* output - distance in kilometers */ /* Get the distance in miles. */ printf("Enter the distance in miles> "); scanf("%lf", &miles); /* Convert the distance to kilometers. */ kms = KMS_PER_MILE * miles; /* Display the distance in kilometers. */ printf("That equals %f kilometers.\n", kms); return (0); } Memory Stack → KMS_PER_MILE 1.609

→ Memory Stack 1.609 /* * Converts distance in miles to kilometers. */ #include <stdio.h> /* printf, scanf definitions */ #define KMS_PER_MILE 1.609 /* conversion constant*/ int main(void) { double miles, /* input - distance in miles. */ kms; /* output - distance in kilometers */ /* Get the distance in miles. */ printf("Enter the distance in miles> "); scanf("%lf", &miles); /* Convert the distance to kilometers. */ kms = KMS_PER_MILE * miles; /* Display the distance in kilometers. */ printf("That equals %f kilometers.\n", kms); return (0); } Memory Stack KMS_PER_MILE 1.609 →

→ Memory Stack 1.609 junk junk miles kms /* * Converts distance in miles to kilometers. */ #include <stdio.h> /* printf, scanf definitions */ #define KMS_PER_MILE 1.609 /* conversion constant*/ int main(void) { double miles, /* input - distance in miles. */ kms; /* output - distance in kilometers */ /* Get the distance in miles. */ printf("Enter the distance in miles> "); scanf("%lf", &miles); /* Convert the distance to kilometers. */ kms = KMS_PER_MILE * miles; /* Display the distance in kilometers. */ printf("That equals %f kilometers.\n", kms); return (0); } Memory Stack KMS_PER_MILE 1.609 miles → junk kms junk

→ Memory Stack 1.609 junk junk miles kms /* * Converts distance in miles to kilometers. */ #include <stdio.h> /* printf, scanf definitions */ #define KMS_PER_MILE 1.609 /* conversion constant*/ int main(void) { double miles, /* input - distance in miles. */ kms; /* output - distance in kilometers */ /* Get the distance in miles. */ printf("Enter the distance in miles> "); scanf("%lf", &miles); /* Convert the distance to kilometers. */ kms = KMS_PER_MILE * miles; /* Display the distance in kilometers. */ printf("That equals %f kilometers.\n", kms); return (0); } Memory Stack KMS_PER_MILE 1.609 miles junk → kms junk

→ Memory Stack 1.609 junk junk miles kms /* * Converts distance in miles to kilometers. */ #include <stdio.h> /* printf, scanf definitions */ #define KMS_PER_MILE 1.609 /* conversion constant*/ int main(void) { double miles, /* input - distance in miles. */ kms; /* output - distance in kilometers */ /* Get the distance in miles. */ printf("Enter the distance in miles> "); scanf("%lf", &miles); /* Convert the distance to kilometers. */ kms = KMS_PER_MILE * miles; /* Display the distance in kilometers. */ printf("That equals %f kilometers.\n", kms); return (0); } Memory Stack KMS_PER_MILE 1.609 miles junk → kms junk

→ Memory Stack 1.609 125.0 junk miles kms /* * Converts distance in miles to kilometers. */ #include <stdio.h> /* printf, scanf definitions */ #define KMS_PER_MILE 1.609 /* conversion constant*/ int main(void) { double miles, /* input - distance in miles. */ kms; /* output - distance in kilometers */ /* Get the distance in miles. */ printf("Enter the distance in miles> "); scanf("%lf", &miles); /* Convert the distance to kilometers. */ kms = KMS_PER_MILE * miles; /* Display the distance in kilometers. */ printf("That equals %f kilometers.\n", kms); return (0); } Memory Stack KMS_PER_MILE 1.609 miles 125.0 → kms junk

→ Memory Stack 1.609 125.0 junk miles kms /* * Converts distance in miles to kilometers. */ #include <stdio.h> /* printf, scanf definitions */ #define KMS_PER_MILE 1.609 /* conversion constant*/ int main(void) { double miles, /* input - distance in miles. */ kms; /* output - distance in kilometers */ /* Get the distance in miles. */ printf("Enter the distance in miles> "); scanf("%lf", &miles); /* Convert the distance to kilometers. */ kms = KMS_PER_MILE * miles; /* Display the distance in kilometers. */ printf("That equals %f kilometers.\n", kms); return (0); } Memory Stack KMS_PER_MILE 1.609 miles 125.0 kms junk →

→ Memory Stack 1.609 125.0 201.125 miles kms /* * Converts distance in miles to kilometers. */ #include <stdio.h> /* printf, scanf definitions */ #define KMS_PER_MILE 1.609 /* conversion constant*/ int main(void) { double miles, /* input - distance in miles. */ kms; /* output - distance in kilometers */ /* Get the distance in miles. */ printf("Enter the distance in miles> "); scanf("%lf", &miles); /* Convert the distance to kilometers. */ kms = KMS_PER_MILE * miles; /* Display the distance in kilometers. */ printf("That equals %f kilometers.\n", kms); return (0); } Memory Stack KMS_PER_MILE 1.609 miles 125.0 kms 201.125 →

→ Memory Stack 1.609 125.0 201.125 miles kms /* * Converts distance in miles to kilometers. */ #include <stdio.h> /* printf, scanf definitions */ #define KMS_PER_MILE 1.609 /* conversion constant*/ int main(void) { double miles, /* input - distance in miles. */ kms; /* output - distance in kilometers */ /* Get the distance in miles. */ printf("Enter the distance in miles> "); scanf("%lf", &miles); /* Convert the distance to kilometers. */ kms = KMS_PER_MILE * miles; /* Display the distance in kilometers. */ printf("That equals %f kilometers.\n", kms); return (0); } Memory Stack KMS_PER_MILE 1.609 miles 125.0 kms 201.125 →

→ Memory Stack 1.609 125.0 201.125 miles kms /* * Converts distance in miles to kilometers. */ #include <stdio.h> /* printf, scanf definitions */ #define KMS_PER_MILE 1.609 /* conversion constant*/ int main(void) { double miles, /* input - distance in miles. */ kms; /* output - distance in kilometers */ /* Get the distance in miles. */ printf("Enter the distance in miles> "); scanf("%lf", &miles); /* Convert the distance to kilometers. */ kms = KMS_PER_MILE * miles; /* Display the distance in kilometers. */ printf("That equals %f kilometers.\n", kms); return (0); } Memory Stack KMS_PER_MILE 1.609 miles 125.0 kms 201.125 →

→ Memory Stack 1.609 125.0 201.125 miles kms /* * Converts distance in miles to kilometers. */ #include <stdio.h> /* printf, scanf definitions */ #define KMS_PER_MILE 1.609 /* conversion constant*/ int main(void) { double miles, /* input - distance in miles. */ kms; /* output - distance in kilometers */ /* Get the distance in miles. */ printf("Enter the distance in miles> "); scanf("%lf", &miles); /* Convert the distance to kilometers. */ kms = KMS_PER_MILE * miles; /* Display the distance in kilometers. */ printf("That equals %f kilometers.\n", kms); return (0); } Memory Stack KMS_PER_MILE 1.609 miles 125.0 kms 201.125 →

→ Memory Stack /* * Converts distance in miles to kilometers. */ #include <stdio.h> /* printf, scanf definitions */ #define KMS_PER_MILE 1.609 /* conversion constant*/ int main(void) { double miles, /* input - distance in miles. */ kms; /* output - distance in kilometers */ /* Get the distance in miles. */ printf("Enter the distance in miles> "); scanf("%lf", &miles); /* Convert the distance to kilometers. */ kms = KMS_PER_MILE * miles; /* Display the distance in kilometers. */ printf("That equals %f kilometers.\n", kms); return (0); } Memory Stack →