Agenda Computer Languages How to Write a Simple C Program

Slides:



Advertisements
Similar presentations
CSE 105 Structured Programming Language (C)
Advertisements

Write a program step by step. Step 1: Problem definition. Given the coordinate of two points in 2-D space, compute and print their straight distance.
1 Lecture 1  Getting ready to program  Hardware Model  Software Model  Programming Languages  The C Language  Software Engineering  Programming.
Program Flow Charting How to tackle the beginning stage a program design.
Chapter 1 Introduction to C Programming. 1.1 INTRODUCTION This book is about problem solving with the use of computers and the C programming language.
Starting Out with C++: Early Objects 5/e © 2006 Pearson Education. All Rights Reserved Starting Out with C++: Early Objects 5 th Edition Chapter 1 Introduction.
CMSC 104, Version 9/011 Introduction to C Topics Compilation Using the gcc Compiler The Anatomy of a C Program 104 C Programming Standards and Indentation.
1 Chapter Two Introduction to the Programming Language C.
C OMPUTER P ROGRAMMING 1 Introduction to the C Language.
C programming Language and Data Structure For DIT Students.
Introduction to C. A Brief History Created by Dennis Ritchie at AT&T Labs in 1972 Originally created to design and support the Unix operating system.
CHAPTER 1: INTORDUCTION TO C LANGUAGE
Chapter 1: Introduction To Computer | SCP1103 Programming Technique C | Jumail, FSKSM, UTM, 2005 | Last Updated: July 2005 Slide 1 Introduction To Computers.
Copyright 2003 Scott/Jones Publishing Brief Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming.
CS102 Introduction to Computer Programming
Agenda What is Computer Programming? The Programming Process
Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 1 Introduction to Computers and Programming.
CHAPTER 4: INTRODUCTION TO COMPUTER ORGANIZATION AND PROGRAMMING DESIGN Lec. Ghader Kurdi.
CSC 125 Introduction to C++ Programming Chapter 1 Introduction to Computers and Programming.
Welcome In The World Of ‘C’.  TEXT BOOK: Programming in ANCI ‘C By: E Balagurusamy. TMH  Reference Books: 1) The ‘C Programming Language By: Kernighan.
Introduction to C Programming. A Brief History u Created by Dennis Ritchie at AT&T Labs in 1972 u Originally created to design and support the Unix operating.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming 1.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
1 Computing Software. Programming Style Programs that are not documented internally, while they may do what is requested, can be difficult to understand.
Introduction of C++ language. C++ Predecessors Early high level languages or programming languages were written to address a particular kind of computing.
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
Chapter 3: Completing the Problem- Solving Process and Getting Started with C++ Introduction to Programming with C++ Fourth Edition.
CSCI 171 Presentation 1. Computer Software System Software –Operating systems –Utility programs –Language compilers Application Software.
CSCI 130 Chapter 1. History of C Bell Telephone Laboratories (1972) Dennis Ritchie (also created UNIX) A - B - C.
Computer Programming A program is a set of instructions a computer follows in order to perform a task. solve a problem Collectively, these instructions.
Programming With C.
History of C 1950 – FORTRAN (Formula Translator) 1959 – COBOL (Common Business Oriented Language) 1971 – Pascal Between Ada.
INTRODUCTION TO COMPUTING CHAPTER NO. 04. Programming Languages Program Algorithms and Pseudo Code Properties and Advantages of Algorithms Flowchart (Symbols.
Introduction to Computer Application (IC) MH Room 517 Time : 7:00-9:30pm.
C Language: Introduction
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.
I Power Higher Computing Software Development Development Languages and Environments.
CPS120: Introduction to Computer Science Compiling a C++ Program From The Command Line.
 Computer Languages Computer Languages  Machine Language Machine Language  Assembly Language Assembly Language  High Level Language High Level Language.
LESSON 1 Introduction to Programming Language. Computer  Comprised of various devices that are referred to as HARDWARE.  The computer programs that.
Computer Programming A simple example /* HelloWorld: A simple C program */ #include int main (void) { printf (“Hello world!\n”); return.
Chapter 11  Getting ready to program  Hardware Model  Software Model  Programming Languages  Facts about C++  Program Development Process  The Hello-world.
An overview of C Language. Overview of C C language is a general purpose and structured programming language developed by 'Dennis Ritchie' at AT &T's.
Principles of Programming CSEB134 : BS/ CHAPTER Fundamentals of the C Programming Language.
Copyright © 2014 Pearson Addison-Wesley. All rights reserved. Chapter 2 C++ Basics.
1 Types of Programming Language (1) Three types of programming languages 1.Machine languages Strings of numbers giving machine specific instructions Example:
Chapter 1: Introduction to Computers and Programming.
L071 Introduction to C Topics Compilation Using the gcc Compiler The Anatomy of a C Program Reading Sections
Introduction to Computer Programming Concepts M. Uyguroğlu R. Uyguroğlu.
INTRODUCTION TO PROGRAMING System Development Mansoura October 2015.
BIL 104E Introduction to Scientific and Engineering Computing Lecture 1.
2.1 First C Program. First Program Open visual studio, click new file Save as “programName.c” – Program must start with letter and have no spaces – Must.
Introduction to C Topics Compilation Using the gcc Compiler
UMBC CMSC 104 – Section 01, Fall 2016
CSCI-235 Micro-Computer Applications
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.
History of ‘C’ Root of the morden language is ALGOL It’s first
Introduction to C Topics Compilation Using the gcc Compiler
Introduction to C Programming Language
Welcome In The World Of ‘C’.  TEXT BOOK: Programming in ANSI ‘C By: E Balagurusamy. TMH  Reference Books: 1) The ‘C Programming Language By: Kernighan.
Introduction to Computer Programming
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
1) C program development 2) Selection structure
Govt. Polytechnic,Dhangar
Creating your first C program
King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1 Done By: Asmal Alosaimi Edited By: Fatimah Alakeel.
King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1 Done By: Asmal Alosaimi Edited By: Fatimah Alakeel.
Introduction to Computer Programming
C programming Language
Introduction to C Topics Compilation Using the gcc Compiler
Presentation transcript:

Agenda Computer Languages How to Write a Simple C Program Machine Language High-Level Programming Language Features of C Programming Language How to Write a Simple C Program How to Record a C Program (typescript)

Computer Programs A program is a set of instructions to tell the computer what to do. In order to better understand the programming process, we will first see how computer programs have developed over the past 50 years.

Computers Computers are electronic devices that transfer and store data in wires (or gates). Because the computer is an electronic device, the data within these wires or gates are either ON or OFF (like a light switch). A collection of these ON and OFF combinations are used to represent data in the form of binary code (eg 010100001010111 )

Evolution of Programs Early programmers needed to write programs using binary code or “machine language” to tell the computer to perform various tasks Although the computer finds machine code efficient to perform tasks, early programmers found writing programs in machine code tedious and time-consuming.

Evolution of Programs Grace Hopper, while working for the U.S. Navy in the 50’s developed a program to convert programs written in symbols to machine language - this was more convenient than writing a program using machine language. This program used symbols to represent operations. Unfortunately, these programs didn’t work on all computers

Evolution of Programs High-level languages were developed to allow the program to be run on many different computer systems. These “high-level” languages are considered “portable” programming languages since they can run on many different computers. The programs are written in a form easily understood by the programmers (source code) and then a “compiler” program converts the source code into machine code to be run by the computer. Examples of high-level languages: FORTRAN, COBOL & C

C Programming Language The C programming language was developed by Dennis Ritchie at Bell AT&T labs in the early 1970s. Dennis Ritchie and Ken Thompson used the C programming language to rewrite the UNIX operating system in 1973. This contributed to the portability and popularity of C as UNIX operating system became widely accepted.

Features of C Programming Language C is portable (can write and compile C programs on many different computer systems without major adjustments) C is powerful, but also efficient. C conforms to the ASNI standard for programming languages C provides the basis for more complex programming languages such as C++

Steps to Create a Program Step 1: Determine the requirements for the program (inputs, outputs, formulas) Step 2: Plan out on paper the logic of the program (flowchart, pseudo code) Step 3: Use Text editor to enter program (Source Code) Step 4: Walk through program’s logic and syntax (look for errors) Step 5: Compile the source code into an executable file Step 6: Run the executable file & test the program’s logic as much as possible.

Debugging a Program Debugging a program is the process of finding and removing errors from your program if it fails to compile or run properly The compiler will NOT create an executable file if the source code contains syntax errors (but compiler will give error messages to help solve problem) If you can compile your source code, errors can still occur due to improper logic, structure, or design approach.

Writing a Simple C Program Indicates to include a file that provides “standard input / output” functions (printf, scanf) which will be linked when source file is compiled #include <stdio.h> main () { printf (“Hello World!\n”); }

Writing a Simple C Program #include <stdio.h> main () { printf (“Hello World!\n”); } Indicates main function or “main part” of the program. All C programs have one main function. Note all lowercase. Syntax may also allow: main (void) int main (void)

Writing a Simple C Program #include <stdio.h> main () { printf (“Hello World!\n”); } Notice braces follow the main function. Other functions or commands are placed within these brackets to be executed when main function is run or “called” begin end

Writing a Simple C Program #include <stdio.h> main () { printf (“Hello World!\n”); } Notice how commands within braces are indented to “stand-out”. This allows programmers to be able to easily read code. Indenting is very important!

Writing a Simple C Program #include <stdio.h> main () { printf (“Hello World!\n”); } The printf command allows the display of output to be formatted: Some special codes include: \n - new line \t - tab (indent) \a - beep (alarm) Note: lowercase

Writing a Simple C Program #include <stdio.h> main () { printf (“Hello World!\n”); } Most C commands end with a semi-colon.

Writing a Simple C Program Task: Write a C program to display the following information on a separate line: Your name Your student number Your section Tell us about yourself

Typescript The script command in the Unix operating system is like a “tape recorder”: Entering command script starts recording all output on screen is saved to a file called typescript Entering command exit stops recording Refer to Assignment #0 for practice of printing out - Assignment is not for marks.