C programming Language and Data Structure For DIT Students.

Slides:



Advertisements
Similar presentations
Programming In C++ Spring Semester 2013 Lecture 2 Programming In C++, Lecture 2.
Advertisements

Introduction to C Programming CE Lecture 1 Introduction to C.
Three types of computer languages
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?
Introduction to C Programming Overview of C Hello World program Unix environment C programming basics.
1 ICS103 Programming in C Lecture 2: Introduction to C (1)
1 Chapter Two Introduction to the Programming Language C.
Introduction to C Programming
Introduction to C language
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.
Computer Science 210 Computer Organization Introduction to C.
COMPUTER SCIENCE I C++ INTRODUCTION
Introducing Java.
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.
“C” Programming Language What is language ? Language is medium of communication. If two persons want to communicate with each other, they have to use.
Programming Design Ku-Yaw Chang Assistant Professor, Department of Computer Science and Information Engineering Da-Yeh University.
Basics of “C” Programming
Gator Engineering 1 Chapter 2 C Fundamentals Copyright © 2008 W. W. Norton & Company. All rights reserved.
History of C and C++ C++ evolved from C ANSI C C++ “spruces up” C
H.Melikian Introduction on C C is a high-level programming language that forms the basis to other programming languages such as C++, Perl and Java. It.
Constants in C A Presentation On Department of Computer & Information Technology, M.S.P.V.L. Polytechnic College, Pavoorchatram.
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.
King Saud University College of applied studies and community services CSC 1101 Computer Programming I Lecture 2.
EPSII 59:006 Spring Introduction to C More Administrative Details The C Programming Language How a computer processes programs Your first C program.
Lecture #5 Introduction to C++
Week 1 Algorithmization and Programming Languages.
C++ Basics C++ is a high-level, general purpose, object-oriented programming language.
C programming language was developed in the seventies by a group of at the Bell Telephone lab. The C language was the outline of two earlier languages.
CSC141 Introduction to Computer Programming Teacher: AHMED MUMTAZ MUSTEHSAN Lecture - 6.
CSCI 3133 Programming with C Instructor: Bindra Shrestha University of Houston – Clear Lake.
Constants, Variables and Data types in C The C character Set A character denotes any alphabet, digit or special symbol used to represent information.
Agenda Computer Languages How to Write a Simple C Program
Structured Programming (4 Credits) HNDIT Week 2 – Learning Outcomes Design an algorithmic solution for simple problem such as computation of a factorial,
Course Title Object Oriented Programming with C++ instructor ADEEL ANJUM Chapter No: 03 Conditional statement 1 BY ADEEL ANJUM (MSc-cs, CCNA,WEB DEVELOPER)
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.
MAHENDRAN. Session Objectives Session Objectives  Discuss the Origin of C  Features of C  Characteristics of C  Current Uses of C  “C” Programming.
Introduction to C Programming
Evolution of C and C++ n C was developed by Dennis Ritchie at Bell Labs (early 1970s) as a systems programming language n C later evolved into a general-purpose.
1 Types of Programming Language (1) Three types of programming languages 1.Machine languages Strings of numbers giving machine specific instructions Example:
BASIC C PROGRAMMING LANGUAGE TUTORIAL infobizzs.com.
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.
Introduction to C Programming I Subject: T0016 – ALGORITHM AND PROGRAMMING Year: 2013.
BIL 104E Introduction to Scientific and Engineering Computing Lecture 1.
CSE-102: PROGRAMMING FUNDAMENTALS LECTURE 3: BASICS OF C Course Instructor: Syed Monowar Hossain 1.
From Algorithms to Programs Both are sets of instructions on how to do a task Algorithm: –talking to humans, easy to understand –in plain (English) language.
Computer Science 210 Computer Organization
CSC201: Computer Programming
Introduction to C Language
C Programming Hardik H. Maheta.
C Language VIVA Questions with Answers
Intro to Programming Week # 1 Hardware / Software Lecture # 2
Getting Started with C.
BY GAWARE S.R. COMPUTER SCI. DEPARTMENT
Introduction to C Programming Language
' C ' PROGRAMMING SRM-MCA.
Lecture2.
Choice of Programming Language
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.
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.
Computer Science 210 Computer Organization
Basics of ‘C’.
Introduction to C Programming
Programming Fundamentals Lecture #3 Overview of Computer Programming
C programming Language
Introduction to Computer Programming
Basic Programming Lab C.
Presentation transcript:

C programming Language and Data Structure For DIT Students

Course Detail Theory100 Piratical 100 Total 200

Introduction to C Programming Introduction

Books n “Turbo C Programming for PC”, Robert Lafore, SAMS n “Data Structure”,Schaum’s Series

Language? n Source of Communication between two persons. –Example: Human –To- Human OR n Source of Communication between User and Computer is called programming language. –Example: Human –To- Machine

Program Set of instructions which perform any specific task is called program.

What is programming? n Series of instructions to a computer to achieve a task n Instructions must be written in a way the computer can understand n Programming languages are used to write programs n Once the code (language) of a program has been written, it must be executed (run, started). n Some programming languages (like C, C++ or Java) require the code to be compiled (translated to binary) before it can be started.

History of C language YearLanguageDeveloper 1960 ALGOL (Algorithmic Language) Internal Committee 1967 BCPL (Basic Combined Programming Language) Martin Richards 1970 BKen Thompson 1972 CDennis Ritchie

What is C? nCnC n A language written by Dennis Ritchie in 1972 at AT&T Bell Labs USA. This was to be the language that UNIX was written in to become the first "portable" language. In recent years C has been used as a general-purpose language because of its popularity with programmers. AT&T-American Telephone and Telegraph UNIX-Uniplexed Information and Computing System or Service

Why C Still Useful? n C provides: u Efficiency, high performance and high quality u Provide functionality through rich set of function libraries u Gateway for other professional languages like C  C++  Java n C is used: u System software, Compilers, Editors u Graphics and Geometry u Databases, operating systems, device drivers u Also used in application programs

Software Development Method n Requirement Specification –Problem Definition n Analysis –Refine, Generalize the problem definition n Design –Develop Algorithm: (A formula or set of steps for solving a particular problem) n Implementation –Write Code n Verification and Testing –Test and Debug the code

How do you write a program? n Decide what steps are needed to complete the task n Write the steps (Algorithm) in pseudo code (written in English) or as a flowchart (graphic symbols) n Translate into the programming language n Try out the program and “debug”.

Sample Pseudo code n Task: add two numbers n Pseudo code ( Algorithm) : 1.Start 2.Get two numbers 3.Add them (a + b) 4.Print the answer 5.End

What does a flowchart look like? n Pseudo code ( Algorithm) : 1.Start 2.Get two numbers 3.Add them (A + B) 4.Print the answer 5.End Start Get 2 numbers A+B Print answer End

n START/END n INPUT/OUTPUT n PROCESS n DECISION Flow Chart symbols

Integrated Development Environments n An integrated development environment (IDE) is a software package that makes it possible to edit, compile, link, execute, and debug a program without leaving the environment. 16

Simple C Program /* A first C Program*/ #include void main() { printf("Hello World"); }

Simple C Program /* A first C Program*/ #include void main() { printf("Hello World"); } Header File Main Function Opening bracket Statement Part Closing Bracket Preprocessor directive

Simple C Program n Line 1: #include n As part of compilation, the C compiler runs a program called the C preprocessor. The preprocessor is able to add and remove code from your source file. n In this case, the directive #include tells the preprocessor to include code from the file stdio.h. n This file contains declarations for functions that the program needs to use. A declaration for the printf function is in this file.

Simple C Program n Line 2: void main() n This statement declares the main function. n A C program can contain many functions but must always have one main function. n A function is a self-contained module of code that can finish some task. n The "void" specifies the return type of main. In this case, nothing is returned to the operating system.

Simple C Program n Line 3: { n This opening bracket denotes the start of the program.

Simple C Program n Line 4: printf("Hello World "); n Printf is a function from a standard C library that is used to print strings to the standard output, normally your screen. n The compiler links code from these standard libraries to the code you have written to produce the final executable. n If there were another printf in this program, its string would print on the next line.

Simple C Program n Line 5: } n This closing bracket denotes the end of the program.

Comment n Comment should be enclosed between /* */ n It is used to increase the readability of the program. n Any number of comments can be given at any place in the program. n Comment cannot be nested example: /* A first C Program*/

n Steps in learning English language n Steps in learning C Alphabets Digits Special-symbols Constants Variables Keywords InstructionProgram Getting started with C Alphabets Sentences Paragraph Words

The C character Set A character denotes any alphabet, digit or special symbol used to represent information. Alphabets A,B, ….,Y, Z a,b, …..,y, z Digits 0,1,2,3,4,5,6,7,8,9 Special Symbols ~ ‘ # % ^ & * ( ) _ - + = | \ { } [ ] : ; “ ‘,. ? /

Constants, Variable and keywords n The alphabets, numbers and special symbol when properly combined form constants, variables and keywords n A constant is a quantity that doesn’t change n A variable is a name given to the location in memory where the constant is stored n Example: 3x + y = 20 3 & 20 are constants, which cannot change x & y can vary or change hence are called variables

Keywords Keywords are the words whose meaning has already been explained to the C compiler Sometimes called reserved words. They cannot be used as variable names. There are only 32 keywords available in c autodoubleifstaticdo breakelseintstructgoto caseenumlongswitchsigned charexternneartypedefwhile constfloatregisteruniondefault continuefarreturnunsignedfor shortvoid

Escape Sequence Certain non printing characters can be expressed in terms of escape sequences n \nnew line n \ttab n \aalert n \\backslash n \”double quote n \0Null n \bBackspace

Data Types C Supports several different types of data, each of which may be represented differently within the computers memory. Basic data types are listed below: Data Type Description Typical Memory int integer quantity 2 bytes char single character 1 bytes float floating point number 4 bytes

Escape Sequences in C n Certain non printing characters can be expressed in terms of escape sequences Character Escape Sequence bell \a backspace \b horizontal tab \t vertical tab \v newline \n carriage return \r quotation mark (“) \” question mark(?) \? backslash (\) \\ null \0

Development with C n Four stages  Editing: Writing the source code by using some IDE or editor  Preprocessing or libraries: Already available routines  compiling: translates or converts source to object code for a specific platform source code -> object code –linking: The object code of a program is linked with libraries that are needed for execution of a program. The linker is used to link the program with libraries. It creates a file with '*.exe' extension.

Program Development Source File Program Object Code File Executable File Preprocessor Modified Source Code in RAM Compiler Linker Editor

Keywords n Sometimes called reserved words. n Are defined as a part of the C language. n Can not be used for anything else! n 32 keywords in C n Examples: –Int –void –while –for