Introduction to C Language

Slides:



Advertisements
Similar presentations
Lecture 2 Introduction to C Programming
Advertisements

Introduction to C Programming
 2000 Prentice Hall, Inc. All rights reserved. Chapter 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line.
Introduction to C++ Programming. A Simple Program: Print a Line of Text // My First C++ Program #include int main( ) { cout
1 CS 161 Introduction to Programming and Problem Solving Chapter 9 C++ Program Components Herbert G. Mayer, PSU Status 10/20/2014.
 C++ programming facilitates a disciplined approach to program design. ◦ If you learn the correct way, you will be spared a lot of work and frustration.
Introduction to C Programming
Your First C++ Program Aug 27, /27/08 CS 150 Introduction to Computer Science I C++  Based on the C programming language  One of today’s most.
CS1061 C Programming Lecture 2: A Few Simple Programs A. O’Riordan, 2004.
 2007 Pearson Education, Inc. All rights reserved Introduction to C Programming.
The C Language 1/31/14.
1 8/30/06CS150 Introduction to Computer Science 1 Your First C++ Program.
Introduction to C Programming
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.
Chapter 3: Introduction to C Programming Language C development environment A simple program example Characters and tokens Structure of a C program –comment.
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.
Chapter 3 Getting Started with C++
Chapter 5: Data Input and Output Department of Computer Science Foundation Year Program Umm Alqura University, Makkah Computer Programming Skills
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 2 Chapter 2 - Introduction to C Programming.
Week 1 Algorithmization and Programming Languages.
COMPUTER PROGRAMMING. A Typical C++ Environment Phases of C++ Programs: 1- Edit 2- Preprocess 3- Compile 4- Link 5- Load 6- Execute Loader Primary Memory.
Computer Programming I Hour 2 - Writing Your First C Program.
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.
Basic Program Construction
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 2 - Introduction to C Programming Outline.
FUNCTIONS. Midterm questions (1-10) review 1. Every line in a C program should end with a semicolon. 2. In C language lowercase letters are significant.
Computer Programming A simple example /* HelloWorld: A simple C program */ #include int main (void) { printf (“Hello world!\n”); return.
 2007 Pearson Education, Inc. All rights reserved. A Simple C Program 1 /* ************************************************* *** Program: hello_world.
1 Structure of Simple C++ Program Chapter 1 09/09/13.
1 Types of Programming Language (1) Three types of programming languages 1.Machine languages Strings of numbers giving machine specific instructions Example:
1 8/30/06CS150 Introduction to Computer Science 1 Your First C++ Program.
SUMMARY OF CHAPTER 2: JAVA FUNDAMENTS STARTING OUT WITH JAVA: OBJECTS Parts of a Java Program.
BIL 104E Introduction to Scientific and Engineering Computing Lecture 1.
1 Lecture 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line of Text 2.3Another Simple C Program: Adding.
CCSA 221 Programming in C CHAPTER 3 COMPILING AND RUNNING YOUR FIRST PROGRAM 1 ALHANOUF ALAMR.
Lecture 4 Computer Programming // sample C++ program #include using namespace std; int main() { cout
STRUCTURED PROGRAMMING Complete C++ Program. Content 2  Main Function  Preprocessor directives  User comments  Escape characters  cout statement.
Introduction to C Topics Compilation Using the gcc Compiler
Chapter 1.2 Introduction to C++ Programming
UMBC CMSC 104 – Section 01, Fall 2016
CSCE 206 Structured Programming in C
User-Written Functions
Prof: Dr. Shu-Ching Chen TA: Samira Pouyanfar Spring 2017
Chapter 1.2 Introduction to C++ Programming
Chapter 1: Introduction to computers and C++ Programming
Chapter 1.2 Introduction to C++ Programming
CSC201: Computer Programming
Introduction to C Language
Chapter 2 - Introduction to C Programming
Computer Programming Chapter 1: Introduction
Chapter 2, Part I Introduction to C Programming
Chapter 2 part #1 C++ Program Structure
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.
Introduction to C Topics Compilation Using the gcc Compiler
Getting Started with C.
Introduction to C Topics Compilation Using the gcc Compiler
Chapter 2 - Introduction to C Programming
Chapter 2 - Introduction to C Programming
Chapter 2 - Introduction to C Programming
Chapter 2 - Introduction to C Programming
Creating your first C program
Chapter 2 - Introduction to C Programming
Programming Fundamentals Lecture #3 Overview of Computer Programming
Introduction to Computer Programming
Chapter 2 - Introduction to C Programming
Introduction to C Topics Compilation Using the gcc Compiler
Introduction to C Programming
Switch Case Structures
Introduction to C Programming
Presentation transcript:

Introduction to C Language Chapter Four 

Outline The C character set. Simple Program. Description of the Program. General Structure of any C program.

The C character set The following program shows the major components of a C program as indicated above. The lines are numbered to reference them, they are not part of the C code. You don’t need to worry now about the logic of this program.

Simple Program 1. #include <stdio.h> 2. void main( ) 3. { 4. printf( "Welcome " ); 5. printf( "to C!\n" ); 6. /* end function main */ 7. }

Line1: It includes a header file called standard 1. #include <stdio.h> 2. void main( ) 3. { 4. printf( "Welcome " ); 5. printf( "to C!\n" ); 6. /* end function main */ 7. } Line1: It includes a header file called standard input and output header file. This file is important in order to introduce data to the program via standard input (such as the keyboard) and to display data on a standard output (such as the screen).

1. #include <stdio.h> 2. void main( ) 3. { 4. printf( "Welcome " ); 5. printf( "to C!\n" ); 6. /* end function main */ 7. } Line 2 : Dcelares a function called name of type void. Inside the parentheses ( ) we can include arguments (will be discussed later).

1. #include <stdio.h> 2. void main( ) 3. { 4. printf( "Welcome " ); 5. printf( "to C!\n" ); 6. /* end function main */ 7. } Lines 3 and 7 : Include the left brace { and the right brace }. We refer to the statements within these braces as compound statements since they are surrounded by these braces.

Lines 4 , 5 : are called statements. 1. #include <stdio.h> 2. void main( ) 3. { 4. printf( "Welcome " ); 5. printf( "to C!\n" ); 6. /* end function main */ 7. } Lines 4 , 5 : are called statements.

1. #include <stdio.h> 2. void main( ) 3. { 4. printf( "Welcome " ); 5. printf( "to C!\n" ); 6. /* end function main */ 7. } Line 6 : Includes /* end function main*/. This is a comment and is ignored by the compiler.

General Structure of any C program The general skeleton (structure) of any C program is: #include <stdio.h> void main( ) { ……… }

Notice that, because of the different standards, the skeleton of the program can be written as follow: #include <stdio.h> int main( ) /* instead of void main( ) */ { ……… return 0; /* as a result of using int main( ) */ }   The right brace } and the left brace { are referred to as Compound Statements.