1 Key Concepts:  Why C?  Life Cycle Of a C program,  What is a computer program?  A program statement?  Basic parts of a C program,  Printf() function?

Slides:



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

IT 325 OPERATING SYSTEM C programming language. Why use C instead of Java Intermediate-level language:  Low-level features like bit operations  High-level.
Chapter 3: Beginning Problem Solving Concepts for the Computer Programming Computer Programming Skills /1436 Department of Computer Science.
Principles of Programming Fundamental of C Programming Language and Basic Input/Output Function 1.
COSC 120 Computer Programming
Structure of a C program
1 Lecture 2  Input-Process-Output  The Hello-world program  A Feet-to-inches program  Variables, expressions, assignments & initialization  printf()
Three types of computer languages
Introduction to C Programming Overview of C Hello World program Unix environment C programming basics.
1 Key Concepts:  Data types in C.  What is a variable?  Variable Declaration  Variable Initialization  Printf()  Scanf()  Working with numbers in.
1 ICS103 Programming in C Lecture 2: Introduction to C (1)
Chapter 2: Introduction to C++.
C programming Language and Data Structure For DIT Students.
CHAPTER 1: INTORDUCTION TO C LANGUAGE
Chapter 3: Introduction to C Programming Language C development environment A simple program example Characters and tokens Structure of a C program –comment.
C Programming. Chapter – 1 Introduction Study Book for one month – 25% Learning rate Use Compiler for one month – 60%
Program A computer program (also software, or just a program) is a sequence of instructions written in a sequence to perform a specified task with a computer.
Copyright 2003 Scott/Jones Publishing Brief Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming.
Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 1 Introduction to Computers and Programming.
Introduction to Java Appendix A. Appendix A: Introduction to Java2 Chapter Objectives To understand the essentials of object-oriented programming in Java.
Basics of “C” Programming
CIS Computer Programming Logic
Goals of Course Introduction to the programming language C Learn how to program Learn ‘good’ programming practices.
C Programming Lecture 4 : Variables , Data Types
C Tokens Identifiers Keywords Constants Operators Special symbols.
The Java Programming Language
Program A computer program (also software, or just a program) is a sequence of instructions written in a sequence to perform a specified task with a computer.
Programming With C.
History of C 1950 – FORTRAN (Formula Translator) 1959 – COBOL (Common Business Oriented Language) 1971 – Pascal Between Ada.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-1 Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley.
Lecture #5 Introduction to C++
Chapter 2. C++ Program Structure C++ program is a collection of subprograms Subprograms in C++ are called FUNCTIONS Each function performs a specific.
Lecture 3: The parts of a C++ program Professor: Dr. Miguel Alonso Jr. Fall 2008 CGS2423/COP1220.
Week 1 Algorithmization and Programming Languages.
Copyright © 2012 Pearson Education, Inc. Chapter 2: Introduction to C++
Copyright © 2015, 2012, 2009 Pearson Education, Inc., Publishing as Addison-Wesley All rights reserved. Chapter 2: Introduction to C++
Chapter 2 part #1 C++ Program Structure
CSCI 3133 Programming with C Instructor: Bindra Shrestha University of Houston – Clear Lake.
Spring 2009 Programming Fundamentals I Java Programming XuanTung Hoang Lecture No. 8.
 2007 Pearson Education, Inc. All rights reserved. A Simple C Program 1 /* ************************************************* *** Program: hello_world.
Silberschatz and Galvin  C Programming Language Kingdom of Saudi Arabia Ministry of Higher Education Al-Majma’ah University College of Education.
Scott Marino MSMIS Kean University MSAS5104 Programming with Data Structures and Algorithms Week 1 Scott Marino.
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.
C is a high level language (HLL)
Sudeshna Sarkar, IIT Kharagpur 1 Programming and Data Structure Sudeshna Sarkar Lecture 3.
Introduction to C Programming
1 Types of Programming Language (1) Three types of programming languages 1.Machine languages Strings of numbers giving machine specific instructions Example:
1 C Syntax and Semantics Dr. Sherif Mohamed Tawfik Lecture Two.
Chapter 1 slides1 What is C? A high-level language that is extremely useful for engineering computations. A computer language that has endured for almost.
INTRODUCTION TO PROGRAMING System Development Mansoura October 2015.
2.1 The Part of a C++ Program. The Parts of a C++ Program // sample C++ program #include using namespace std; int main() { cout
History of C and basics of Programming
Numbers in ‘C’ Two general categories: Integers Floats
CSCE 206 Structured Programming in C
Prof: Dr. Shu-Ching Chen TA: Samira Pouyanfar Spring 2017
Chapter 1: Introduction to computers and C++ Programming
CSC201: Computer Programming
Introduction to C Language
C Language VIVA Questions with Answers
Getting Started with C.
Introduction to C Programming Language
' C ' PROGRAMMING SRM-MCA.
INTRODUCTION c is a general purpose language which is very closely associated with UNIX for which it was developed in Bell Laboratories. Most of the programs.
Govt. Polytechnic,Dhangar
Introduction C is a general-purpose, high-level language that was originally developed by Dennis M. Ritchie to develop the UNIX operating system at Bell.
C programming Language
WEEK-2.
C++ Programming Basics
Course Outcomes of Programming In C (PIC) (17212, C203):
Getting Started With Coding
Presentation transcript:

1 Key Concepts:  Why C?  Life Cycle Of a C program,  What is a computer program?  A program statement?  Basic parts of a C program,  Printf() function?  Goal: Write your first C program

2 General Knowledge  Computer Consists of Hardware Software  Programmers

3 What is a computer program (software)?  Is a set of instructions that tells the computer what to do.  There are about 400 programming languages.  Each language has its own: Syntax Grammar Application

4 A Brief History of Programming Languages  Machine Languages (0, 1)  Assembly Languages  More advanced than machine languages

5 Cont…  High Level Languages  Have English like syntax  Has an Interpreter or compiler.  Are divided into 2 categories:  Procedural (Conventional)  Object Oriented

6  Procedural Language: Problem is solved based on the tasks to be performed. A segment of code is written to accomplish each task. The segment of code is called a procedure / function. Ex: C

7 Object Oriented Languages:  Problem is solved based on the objects involved.  Objects have properties and methods (behavior).  Ex: C++

8 “C” Language:  Was introduced by “Dennis Ritchie” at Bell Labs in 1970 for writing the UNIX operating system.  Is a procedural language.  Uses available libraries to read, write, do math, use files, …  Can access bits of computer memory.  Can be executed on any platform.

9 Why C?  It is a small, high level, and structured language.  It can manipulate bits of computer memory.  Does not put high demand on memory.  Can run on different platforms with very little modification.

10 C Program’s Life Cycle:  Source file (.c) Object file (.obj)  Library files Executable file (.exe) Compiler Linker

11 What are C libraries?  Pre-compiled functions that come with the C compiler.  The functions are grouped in different packages called libraries.  To use functions included in a library, include the header file specified for that library in your program.  Ex: #include

12 Basic parts of a C program: // Display Hello World to screen: #include main() { printf(“Hello World!” ); }

13 What is preprocessor?  Is a program that processes the C program before it is compiled.  It looks for the lines that begin with # Preprocessor directive: Is any line that begins with #. ex: #include

14 Few things about the C Language: Is case sensitive. It must have a function main(). Program execution begins with function main(). The body of every function is surrounded in { } Every program statement ends with a ; Spaces are ignored in the code. Comments in C:  Comments are used for documentation and clarity of the code.  // single line comment….  /* multi-line comment */

15 Program Statements in C  Single statement: Is a combination of:  keywords,  Variables,  Literals: 334, “Hello”, 3.14  other tokens: ( ) ; int Ends with a ;  Compound statement: 2 or more C statements. Enclosed in {.. }.

16 Terminologies:  Token: Is a part of a statement that cannot be broken into smaller piece by the compiler, Ex: int, main, (, {, ;  Keyword: A word that has special meaning in the language. In C all keywords are in lower case. Ex: int, float, double, if, else, while, break, …

17 printf( ) function:  Is used to write to the standard output (screen).  Is included in one of the C libraries.  Include stdio.h header file in order to use this function. #include  Syntax: printf (“Whatever you wish to write!”);

18 Escape Character (\..):  Can be used inside the “...” of printf, to format the output: \n inserts a new line in the output \t inserts a tab \\ writes \ \” writes “ \’ writes ‘

19.  Ex: Write a C program to write the following to the screen: Your Name CIT105 This is my first C program ===================================

20 Types of data:  Numeric: Integer = whole numbers Floating point = real numbers  Non-numeric: Character: ‘a’ String: “anything between double quotes”

21 Data Types of numeric data:  Data types for whole Numbers: char 1 byte short 2 Bytes -32, ,767 int 2 bytes long 4 bytes -2 billion.. 2 billion  Real numbers: float 4 bytes (7 digits after.) double 8 bytes (15 digits after.) The size/range of each data type depends on your computer.

22 Cont…  unsigned … The char, short, int, long have unsigned versions as well. unsigned char 1 byte  char data type: Takes one byte in memory. Can store small integers. Can store single characters: ‘g’  String data: There is no string data type in C. “abc” is a string literal / constant. Character arrays can be used to store string data in memory.

23 Next time:  What is a variable?  Working with variables,  Writing variables to the output  Arithmetic Operators in C