Introduction to compilation process March 24. The following slides will show you step by step instruction how to get ready and build C language programs.

Slides:



Advertisements
Similar presentations
An Introduction to Programming By :- Vishal Hirani B.Tech II year (CSE)
Advertisements

Solving Problems with Repetition. Objectives At the end of this topic, students should be able to: Correctly use a while statement in a C# program Correctly.
Repetition Control Structures School of Business Eastern Illinois University © Abdou Illia, Spring 2003 (Week 9, Friday 3/07/2003)
Flow Charts, Loop Structures
Introduction to Flowcharting
Introduction to Flowcharting
Introduction to Flowcharting A Supplement to Starting Out with C++, 4th Edition by Tony Gaddis Published by Addison-Wesley.
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
ALGORITHMS & FLOWCHARTING II
Fundamentals of Algorithms MCS - 2 Lecture # 4
© Janice Regan, CMPT 102, Sept CMPT 102 Introduction to Scientific Computer Programming The software development method algorithms.
Chapter 2- Visual Basic Schneider
Computer Science 1620 Programming & Problem Solving.
1 10/9/06CS150 Introduction to Computer Science 1 for Loops.
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
(C)opyright 2003 Scott/Jones Publishers Introduction to Flowcharting A Supplement to Starting Out with C++, 4th Edition by Tony Gaddis Scott/Jones Publishers.
PRE-PROGRAMMING PHASE
ALGORITHMS AND FLOW CHARTS 1 Adapted from the slides Prepared by Department of Preparatory year Prepared by: lec. Ghader Kurdi.
Chapter 1 Pseudocode & Flowcharts
Copyright 2003 Scott/Jones Publishing Brief Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming.
CCSA 221 Programming in C CHAPTER 2 SOME FUNDAMENTALS 1 ALHANOUF ALAMR.
Introduction to Problem SolvingS1.2.1 Bina © 1998 Liran & Ofir Introduction to Problem Solving Programming in C.
Introduction to Programming Prof. Rommel Anthony Palomino Department of Computer Science and Information Technology Spring 2011.
1 Programming and Problem Solving — Software Engineering (Read Chap. 2)
Programming and Problem Solving — Software Engineering (Read Chap. 2) 1.
General Programming Introduction to Computing Science and Programming I.
Algorithms and Flowcharts for Programming CFD
Lecture 4 Introduction to Programming. if ( grade ==‘A’ ) cout
1 Introduction to Flowcharting. 2 Writing a program Defining the problem –Write down what the program will do Planning –Write down the steps, draw a flowchart.
1 Introduction to Flowcharting. 2 Writing a program Defining the problem –Write down what the program will do Planning –Write down the steps, draw a flowchart.
© 2011 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Stewart Venit ~ Elizabeth Drake Developing a Program.
CS 108 Computing Fundamentals Notes for Thursday September 10, 2015.
Software Life Cycle What Requirements Gathering, Problem definition
Introduction to Video Game Programming (VGP) Mr. Shultz.
Algorithms  Problem: Write pseudocode for a program that keeps asking the user to input integers until the user enters zero, and then determines and outputs.
CMP 131 Introduction to Computer Programming Violetta Cavalli-Sforza Week 3, Lecture 1.
Introducing programming March 24. Program structure Statements to establish the start of the program Variable declaration Program statements (block statements)
Introducing block scheme programming March 17. Algorithm / Flow chart An algorithm or a flowchart is a step-by-step procedure for solving a particular.
You will need Dev C++ to help you with this project. If you do not already have this programming tool on your device you can visit
Topic: Control Statements. Recap of Sequence Control Structure Write a program that accepts the basic salary and allowance amount for an employee and.
© Peter Andreae Java Programs COMP 102 # T1 Peter Andreae Computer Science Victoria University of Wellington.
Program Program is a collection of instructions that will perform some task.
 Prepared by: Eng. Maryam Adel Abdel-Hady
 Prepared by: Eng. Maryam Adel Abdel-Hady
© 2012 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Chapter 3: Top-Down Design with Functions Problem Solving & Program.
Algorithm & Flow Charts Decision Making and Looping
Intro. to Computer Programming Eng. Nehal A. Mohamed Spring Semester-2016.
Lecture 3 Computer Programming -1-. The main steps of program development to solve the problem: 1- problem definition : The problem must be defined into.
 Problem Analysis  Coding  Debugging  Testing.
Introduction to Computing Science and Programming I
Introduction to Programming
Unit 3: ALGORITHMS AND FLOWCHARTS
Algorithms Problem: Write pseudocode for a program that keeps asking the user to input integers until the user enters zero, and then determines and outputs.
Introduction to Programming
Lecture 2 Introduction to Programming
ALGORITHMS & FLOWCHARTING II
PROBLEM SOLVING AND OFFICE AUTOMATION
Introduction to Algorithm Design
Topics discussed in this section:
Introduction to Programming
Introduction to Programming
Introduction to Algorithms and Programming
Introduction to Programming
Running a Java Program using Blue Jay.
Introduction to Programming
Introduction to Programming
Introduction to Programming
Starter Activities GCSE Python.
ICS103 Programming in C 1: Overview of Computers And Programming
Programming Logic and Design Eighth Edition
Presentation transcript:

Introduction to compilation process March 24

The following slides will show you step by step instruction how to get ready and build C language programs in Linux Ubuntu. 2 1.Enter terminal by pressing t 2.To create a folder workspace/programming in you home folder type mkdir -p ~/workspace/programming/ 3.Enter newly created folder cd ~/workspace/programming/ 4.Enter text editor by typing nano first.c

nano editor 3 See the control option at the bottom of the screen. For example to delete line of text press k

Type your program 4 Important!!! Add comments Add indents

Building the program 5 To build(create a binary file) your program type gcc -o build execute

Errors 6 Remove ; Remove & Lets make an error and a warning on purpose

Building a program with errors 7 Notifies us about the syntactical error Notifies us about the warning Even thought program compiles and ready to run, it will not function correctly, thus pay attention to warnings carefully.

Largest of three numbers 8 start read X, Y, Z stop X > Y ? stop yesno max > Z ? Output max Output z yesno Max = XMax = Y Transform the flowchart below to a C language program. See next slide

Largest of three numbers 9

Find whether a number is odd or even Draw a flow chart for the algorithm that checks whether the number is odd or even. Convert the algorithm into C language program 10 start read x stop x % 2 == 0 ? stop yesno Output “even” Output “odd”

Find whether a number is odd or even Type the program in nano editor and compile it with gcc evenodd.c -o evenodd 11

Example of a while loop The program prints out a conversion table from Fahrenheit to Celsius. Draw a corresponding flowchart 12 Program Output

13 start read N stop Count > N ? output sum no yes sum = sum + count * count sum = 0 count = 1 count = count + 1 Example of a for loop The program calculates the following sum: sum = … + N 2

The following slides are your homework assignments 14

15 start read N stop Count > N ? output sum no yes sum = sum + count * (count + 1) sum = 0 count = 1 count = count + 1 Problem 1 Convert to C program Use do{}while() loop construction sum = 1*2 + 2*3 + 3*4 + … + N * (N +1) The following algorithm calculates the sum

16 start read N stop count > N ? output sum no yes prod = prod * count prod = 1 count = 1 count = count + 1 Problem 2 Convert to C program Use for() loop construction The following algorithm calculates factorial

17 start Read X, N stop count > N ? output sum no yes sum = prod * count term = term * X / count term = 1 prod = 1 count = 1 count = count + 1 Problem 3 Use Taylor expansion to represent e x up to N terms. Convert to C program Hint: Use for() loop construction The following algorithm computes e x series up to N terms

18 start Read X, N stop term <.0001 ? output sum no yes sum = prod * count term = term * X / count term = 1 prod = 1 count = 1 count = count + 1 Problem 4 Use Taylor expansion to represent e x up to 4 decimal places. Convert to C program Hint: Use do{}while() loop construction The following algorithm computes e x series up to 4 decimal places