Silberschatz and Galvin  1999 1.1 C Programming Language Kingdom of Saudi Arabia Ministry of Higher Education Al-Majma’ah University College of Education.

Slides:



Advertisements
Similar presentations
Overview of programming in C C is a fast, efficient, flexible programming language Paradigm: C is procedural (like Fortran, Pascal), not object oriented.
Advertisements

C Language.
Programming In C++ Spring Semester 2013 Lecture 2 Programming In C++, Lecture 2.
Chapter 3: Beginning Problem Solving Concepts for the Computer Programming Computer Programming Skills /1436 Department of Computer Science.
 2005 Pearson Education, Inc. All rights reserved Introduction.
1 Chapter 2 Introduction to Java Applications Introduction Java application programming Display ____________________ Obtain information from the.
Principles of Programming Fundamental of C Programming Language and Basic Input/Output Function 1.
Introduction to Computing Lecture 01: Introduction to C Introduction to Computing Lecture 01: Introduction to C Assist.Prof.Dr. Nükhet ÖZBEK Ege University.
Software Development Method. Assignments Due – Homework 0, Warmup Reading – Chapter 2 –
Structure of a C program
C Programming Language 4 Developed in 1972 by Dennis Ritchie at AT&T Bell Laboratories 4 Used to rewrite the UNIX operating system 4 Widely used on UNIX.
1 Lecture 2  Input-Process-Output  The Hello-world program  A Feet-to-inches program  Variables, expressions, assignments & initialization  printf()
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)
Chapter 2 Data Types, Declarations, and Displays
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand the structure of a C-language program. ❏ To write your first C.
C OMPUTER P ROGRAMMING 1 Introduction to the C Language.
C programming Language and Data Structure For DIT Students.
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%
Chapter 2 Getting Started in C Programming
Goals of Course Introduction to the programming language C Learn how to program Learn ‘good’ programming practices.
(1 - 2) C Language Elements H&K Chapter 2 Instructor - Andrew S. O’Fallon CptS 121 (August 28, 2015) Washington State University.
Chapter 2 Overview of C Part I J. H. Wang ( 王正豪 ), Ph. D. Assistant Professor Dept. Computer Science and Information Engineering National Taipei University.
C Tokens Identifiers Keywords Constants Operators Special symbols.
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.
Lecture #5 Introduction to C++
Constants Numeric Constants Integer Constants Floating Point Constants Character Constants Expressions Arithmetic Operators Assignment Operators Relational.
 Pearson Education, Inc. All rights reserved Introduction to Java Applications.
Introduction to Programming
CSCI 3133 Programming with C Instructor: Bindra Shrestha University of Houston – Clear Lake.
Overview of C. C—a high-level programming language developed in 1972 by Dennis Ritchie at AT&T Bell Laboratories. We will discuss: –the elements of a.
Programming Fundamentals. Overview of Previous Lecture Phases of C++ Environment Program statement Vs Preprocessor directive Whitespaces Comments.
1 Lexical Elements, Operators, and the C System. 2 Outline Characters and Lexical Elements Syntax Rules Comments Keywords Identifiers Constants String.
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.
MAHENDRAN. Session Objectives Session Objectives  Discuss the Origin of C  Features of C  Characteristics of C  Current Uses of C  “C” Programming.
Sudeshna Sarkar, IIT Kharagpur 1 Programming and Data Structure Sudeshna Sarkar Lecture 3.
1 Types of Programming Language (1) Three types of programming languages 1.Machine languages Strings of numbers giving machine specific instructions Example:
1 A more complex example Write a program that sums a sequence of integers and displays the result. Assume that the first integer read specifies the number.
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.
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.
Silberschatz and Galvin  C Programming Language Kingdom of Saudi Arabia Ministry of Higher Education Al-Majma’ah University College of Education.
Chapter 2 Variables and Constants. Objectives Explain the different integer variable types used in C++. Declare, name, and initialize variables. Use character.
Numbers in ‘C’ Two general categories: Integers Floats
Introduction to ‘c’ language
C Language VIVA Questions with Answers
Revision Lecture
Getting Started with C.
BY GAWARE S.R. COMPUTER SCI. DEPARTMENT
Introduction to C Programming Language
Lecture2.
By: Syed Shahrukh Haider
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.
Visit for more Learning Resources
Variables In programming, we often need to have places to store data. These receptacles are called variables. They are called that because they can change.
Basics of ‘C’.
Govt. Polytechnic,Dhangar
Variables T.Najah Al_Subaie Kingdom of Saudi Arabia
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.
WEEK-2.
The C Language: Intro.
C – Programming Language
C Language B. DHIVYA 17PCA140 II MCA.
Course Outcomes of Programming In C (PIC) (17212, C203):
Variables and Constants
Getting Started With Coding
Presentation transcript:

Silberschatz and Galvin  C Programming Language Kingdom of Saudi Arabia Ministry of Higher Education Al-Majma’ah University College of Education - Zulfi Computer Department المملكة العربية السعودية وزارة التعليم العالي جامعة المجمعة كلية التربية بالزلفي قسم الحاسب الآلي Teacher: Chafika LAABIDI OUNI WANNASSI

Silberschatz and Galvin  C Programming Language C is a general-purpose, high-level language that was originally developed by Dennis M. Ritchie to develop the UNIX operating system at Bell Labs. C was originally first implemented on the DEC PDP-11 computer in The UNIX operating system, the C compiler, and essentially all UNIX applications programs have been written in C. The C has now become a widely used professional language for various reasons.

Silberschatz and Galvin  Features Easy to learn Structured language It produces efficient programs. It can handle low-level activities. It can be compiled on a variety of computer platforms.

Silberschatz and Galvin  Facts about C C was invented to write an operating system called UNIX. C is a successor of B language which was introduced around 1970 The language was formalized in 1988 by the American National Standard Institute (ANSI). The UNIX OS was totally written in C.

Silberschatz and Galvin  Facts about C (cont) Today C is the most widely used and popular System Programming Language. Most of the state-of-the-art softwares have been implemented using C. Today's most popular Linux OS and RBDMS MySQL have been written in C.

Silberschatz and Galvin  Why to use C? C was adopted as a system development language because it produces code that runs nearly as fast as code written in assembly language. Some examples of the use of C might be: Operating Systems Databases Functions Variables Statements & Expressions Comments

Silberschatz and Galvin  Example #include Int x; X=12; int main(x) { /*this is my first program in C */ printf("Hello, World! \n",x); return x; }

Silberschatz and Galvin  Example (cont) The first line of the program #include is a preprocessor command, which tells a C compiler to include stdio.h file before going to actual compilation. The next line int main() is the main function where program execution begins.

Silberschatz and Galvin  Example (cont) The next line /*...*/ will be ignored by the compiler and it has been put to add additional comments in the program. So such lines are called comments in the program. The next line printf(...) is another function available in C which causes the message "Hello, World!" to be displayed on the screen. The next line return 0; terminates main()function and returns the value 0.

Silberschatz and Galvin  Data Types int - integer: a whole number, float - floating point value: ie a number with a fractional part, double - a double-precision floating point value. char - a single character. void - valueless special purpose type which we will examine closely in later sections

Silberschatz and Galvin  Data Types (cont) Example: int a; Declares that you want to create an int variable called a. To assign a value to our integer variable we would use the following C statement: a=10;

Silberschatz and Galvin  Identifiers A C identifier is a name used to identify a variable, function, or any other user-defined item. An identifier starts with a letter A to Z or a to z or an underscore _ followed by zero or more letters, underscores, and digits (0 to 9).

Silberschatz and Galvin  Identifiers (cont) C does not allow punctuation characters such $, and % within identifiers. C is a case sensitive programming language. Thus, Manpower and manpower are two different identifiers in C. Examples: mohd zara abc move_name a_123 myname50 _temp j a23b9 retVal

Silberschatz and Galvin  Keywords The following list shows the reserved words in C. These reserved words may not be used as constant or variable or any other identifier names. Autoelselongswitch Breakenumregistertypedef Caseexternreturnunion Charfloatshortunsigned Constforsignedvoid Continuegotosizeofvolatile Defaultifstaticwhile Dointstruct_Packed Double

Silberschatz and Galvin  Whitespace in C Whitespace is the term used in C to describe blanks, tabs, newline characters and comments. Whitespace separates one part of a statement from another and enables the compiler to identify where one element in a statement, such as int, ends and the next element begins.

Silberschatz and Galvin  C Variables A variable is nothing but a name given to a storage area that our programs can manipulate. Each variable in C has a specific type, which determines the size and layout of the variable's memory; The name of a variable can be composed of letters, digits, and the underscore character.

Silberschatz and Galvin  C Variables (cont) TypeDescription Char Typically a single octet(one byte). This is an integer type. Int The most natural size of integer for the machine. FloatA single-precision floating point value. DoubleA double-precision floating point value. VoidRepresents the absence of type.

Silberschatz and Galvin  Variable Definition in C: A variable definition means to tell the compiler where and how much to create the storage for the variable. A variable definition specifies a data type and contains a list of one or more variables of that type as follows: type variable_list; Examples: int i, j, k; char c, ch; float f, salary; double d;

Silberschatz and Galvin  Variable Definition in C (cont) Variables can be initialized (assigned an initial value) in their declaration. type variable_name = value; Examples: int d = 3, f = 5; char x = 'x';

Silberschatz and Galvin  Variable Definition in C (cont) The % Format Specifiers, The % specifiers that you can use in ANSI C are: %c char single character %d (%i) int signed integer %e (%E) float or double exponential format %f float or double signed decimal %g (%G) float or double use %f or %e as required

Silberschatz and Galvin  Variable Definition in C (cont) %o int unsigned octal value %p pointer address stored in pointer %s array of char sequence of characters %u int unsigned decimal %x (%X) int unsigned hex value

Silberschatz and Galvin  Input and Output Functions Input functions, called scanf Output functions, called printf

Silberschatz and Galvin  Input and Output Functions (cont) Example: #include main() int num1, num2; float average; scanf("%d%d",& num1,& num2); average = ( num1+num2 ) / 2 ; printf("Here is the answer... "); printf("\n"); printf("%f",average);

Silberschatz and Galvin 