C OMPUTER P ROGRAMMING 1 Introduction to the C Language.

Slides:



Advertisements
Similar presentations
CS0007: Introduction to Computer Programming Console Output, Variables, Literals, and Introduction to Type.
Advertisements

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.
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.
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?
1 September 6, 2005CS150 Introduction to Computer Science I What Actions Do We Have Part 1 CS150 Introduction to Computer Science I.
 2003 Prentice Hall, Inc. All rights reserved. 1 Machine Languages, Assembly Languages, and High-level Languages Three types of computer languages 1.Machine.
1 ICS103 Programming in C Lecture 2: Introduction to C (1)
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 - Input & Output When we are saying Input that means to feed some data into program. This can be given in the form of file or from command line. C programming.
CSC103: Introduction to Computer and Programming
Using C Programming Language.  The programs that run on a computer are referred to as software.  You’ll learn key programming methodology that are enhancing.
By: Mr. Baha Hanene Chapter 3. Learning Outcomes We will cover the learning outcome 02 in this chapter i.e. Use basic data-types and input / output in.
Principles of Programming Chapter 1: Introduction  In this chapter you will learn about:  Overview of Computer Component  Overview of Programming 
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
Introduction to C++ - How C++ Evolved Most popular languages currently: COBOL, Fortran, C, C++, Java (script) C was developed in 1970s at AT&T (Richie)
Introduction to Java Appendix A. Appendix A: Introduction to Java2 Chapter Objectives To understand the essentials of object-oriented programming in Java.
“C” Programming Language What is language ? Language is medium of communication. If two persons want to communicate with each other, they have to use.
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
C How to Program, 6/e © by Pearson Education, Inc. All Rights Reserved.
1 Agenda Administration Background Our first C program Working environment Exercise Memory and Variables.
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.
Lecture 3: The parts of a C++ program Professor: Dr. Miguel Alonso Jr. Fall 2008 CGS2423/COP1220.
Week 1 Algorithmization and Programming Languages.
Course Title: Introduction to C++ Course Instructor: ADEEL ANJUM Chapter No: 01 1 BY ADEEL ANJUM (MCS, CCNA,WEB DEVELOPER)
 Pearson Education, Inc. All rights reserved Introduction to Java Applications.
THE BASICS OF A C++ PROGRAM EDP 4 / MATH 23 TTH 5:45 – 7:15.
Syntax and Semantics, and the Program Development Process ROBERT REAVES.
Control Structures (B) Topics to cover here: Sequencing in C++ language.
Introducing C++ Programming Lecture 3 Dr. Hebbat Allah A. Elwishy Computer & IS Assistant Professor
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
DOCUMENTATION SECTION GLOBAL DECLARATION SECTION
Agenda Computer Languages How to Write a Simple C Program
CHAPTER 1: INTRODUCTION C++ Programming. CS 241 Course URL: Text Book: C++ How to Program, DETITEL & DEITEL, eighth Edition.
Principles of Programming Chapter 1: Introduction  In this chapter you will learn about:  Overview of Computer Component  Overview of Programming 
JavaScript 101 Introduction to Programming. Topics What is programming? The common elements found in most programming languages Introduction to JavaScript.
Learners Support Publications Introduction to C++
C OMPUTER P ROGRAMMING 1 Input and Variables. I/O S TATEMENTS : I NPUT & V ARIABLES Input is the term used to describe the transfer of information from.
Program Development Cycle 1.Edit program 2.Compile program - translates it from C to machine language 3. Run/execute your program. 4. If not satisfied,
Course Title Object Oriented Programming with C++ instructor ADEEL ANJUM Chapter No: 03 Conditional statement 1 BY ADEEL ANJUM (MSc-cs, CCNA,WEB DEVELOPER)
Silberschatz and Galvin  C Programming Language Kingdom of Saudi Arabia Ministry of Higher Education Al-Majma’ah University College of Education.
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.
Copyright © 2014 Pearson Addison-Wesley. All rights reserved. Chapter 2 C++ Basics.
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:
Chapter 1: Introduction to Computers and Programming.
INTRODUCTION TO PROGRAMING System Development Mansoura October 2015.
Chapter Topics The Basics of a C++ Program Data Types
Prof: Dr. Shu-Ching Chen TA: Samira Pouyanfar Spring 2017
What Actions Do We Have Part 1
CSC201: Computer Programming
Chapter 2, Part I Introduction to C Programming
Basic Elements of C++.
C Language VIVA Questions with Answers
Revision Lecture
Beginning C++ Programming
BY GAWARE S.R. COMPUTER SCI. DEPARTMENT
Introduction to C Programming Language
Basic Elements of C++ Chapter 2.
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.
Programming Funamental slides
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
Course Outcomes of Programming In C (PIC) (17212, C203):
Chapter 1 c++ structure C++ Input / Output
Presentation transcript:

C OMPUTER P ROGRAMMING 1 Introduction to the C Language

T HE C P ROGRAMMING L ANGUAGE C was invented between 1969 and 1973 by Dennis Richie for AT&T Bell Labs. Standardised in 1989 as “ANSI C” C is one of the most widely used languages of all time Designed for cross-platform programming Idea : the same source code can be compiled on different operating systems / hardware C is still used for systems programming : Operating Systems (e.g. UNIX) Embedded Systems (e.g. sensor platforms)

T HE C P ROGRAMMING L ANGUAGE A C program is made up of a group of statements. These statements allow us to control the computer. Using them we can display information on the screen, read information from the keyboard, store information on disk and retrieve it and we can process information in a variety of ways. In this section we will study the statements that arise in writing programs.

T HE C P ROGRAMMING L ANGUAGE We can classify statements as follows: I/O statements, variable declaration statements, variable manipulation statements (e.g. to do arithmetic) and conditional statements. We also look at the use of subprograms, which enable to us to break large programs into meaningful units. Associated with the different types of statement is a set of special words called reserved words (keywords). Every programming language has its own set of reserved words. These words have a special meaning in the language and can only be used for particular purposes.

T HE C P ROGRAMMING L ANGUAGE The following are some of the reserved words of the C language that will be used in this text: int, float, char, if, while All C code and variable names will be printed using the Courier font in these notes.

I/O S TATEMENTS - O UTPUT Output is the term used to describe information that the processor sends to peripheral devices e.g. to display results on a screen or to store information in a disk file. One of the commonest forms of output is that of displaying a message on your screen. In C we use printf() to display output on the screen. The following printf() statement will display the message this is my first program on the screen printf ( “this is my first program” ); This is a single C program statement

I/O S TATEMENTS - O UTPUT In order to execute the statement, it must be part of a complete program. The complete C program to display the message is: #include main() { printf ( “this is my first program“ ); } All C programs start with main() followed by the opening chain bracket {, and finish with a closing chain bracket } The line #include will be explained later

I/O S TATEMENTS - O UTPUT You may have as many statements as you wish between the chain brackets. The chain brackets are used to group a collection of statements together. Such a group is called a compound statement. A single statement is called a simple statement. A compound statement is treated as if it was a simple statement and may be used anywhere that a simple statement may be used. This is a very important feature of C. Other programming languages (e.g. Fortran, BASIC) at the time did not provide compound statements, and it is more difficult to write programs in these languages as a result.

I/O S TATEMENTS - O UTPUT main() and printf() are technically called functions. In simple terms, in C, a function is a named group of statements that carry out some task. The main() function is the one which defines what a C program does when you run it – it carries out the statements contained in main() The printf() function is pre-defined for you. It displays information on the screen. It is one of a large number of pre-defined functions ( library functions) that you may use. Functions will be discussed later and you will see how to define your own functions.

I/O S TATEMENTS - O UTPUT Special characters allow you to enter characters that cannot be expressed directly using a keyboard. They are denoted by a backslash character ‘\’ (known as the escape character) combined with another character. For example, the character ‘ \n’ (called newline) is used in printf() to cause the next output to go onto a new line. The following printf() statement illustrate the use of ‘\n’: printf(“one\ntwo\nthree\n“); produces as output: one two three

I/O S TATEMENTS - O UTPUT It is interesting to note that the following sequence of printf() statements: printf(“one\n”); printf(“two\n”); printf(“three\n“) ; produces identical output to the single printf() on the previous slide i.e. one two three

I/O S TATEMENTS - O UTPUT The practical for this week is to develop some programs that print to the console.