C – Programming Language

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.
Lecture 2 Introduction to C Programming
Introduction to C Programming
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.
Introduction 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.
Basic Elements of C++ Chapter 2.
Computer Science 210 Computer Organization Introduction to C.
Chapter 2 Getting Started in C Programming
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
Sales person receive RM200/week plus 9% of their gross sales for that week. Write an algorithms to calculate the sales person’s earning from the input.
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.
Structure of a C program Preprocessor directive (header file) Program statement } Preprocessor directive Global variable declaration Comments Local variable.
Course Title: Object Oriented Programming with C++ instructor ADEEL ANJUM Chapter No: 03 Conditional statement 1 BY ADEEL ANJUM (MSc-cs, CCNA,WEB DEVELOPER)
Introduction to Programming
VARIABLES, CONSTANTS, OPERATORS ANS EXPRESSION
 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.
1 Types of Programming Language (1) Three types of programming languages 1.Machine languages Strings of numbers giving machine specific instructions Example:
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.
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.
SCP1103 Basic C Programming SEM1 2010/2011 Arithmetic Expressions Week 5.
2.1 The Part of a C++ Program. The Parts of a C++ Program // sample C++ program #include using namespace std; int main() { cout
Numbers in ‘C’ Two general categories: Integers Floats
Introduction to ‘c’ language
Arithmetic Expressions
CSCE 206 Structured Programming in C
Chapter Topics The Basics of a C++ Program Data Types
Computer Science 210 Computer Organization
Chapter 1.2 Introduction to C++ Programming
BASIC ELEMENTS OF A COMPUTER PROGRAM
Chapter 2 - Introduction to C Programming
Programming Fundamental
Basic Elements of C++.
C Language VIVA Questions with Answers
ICS103 Programming in C Lecture 3: Introduction to C (2)
Getting Started with C.
Introduction to C Programming Language
' C ' PROGRAMMING SRM-MCA.
Chapter 2 - Introduction to C Programming
Introduction to C Programming
Basic Elements of C++ Chapter 2.
Visit for more Learning Resources
Computer Science 210 Computer Organization
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.
Chapter 2 - Introduction to C Programming
Chapter 2 - Introduction to C Programming
Chapter 2 - Introduction to C Programming
Introduction to C Programming
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.
Chapter 2 - Introduction to C Programming
elementary programming
C programming Language
WEEK-2.
Chapter 2 - Introduction to C Programming
The C Language: Intro.
CPP Programming Language
Course Outcomes of Programming In C (PIC) (17212, C203):
Introduction to C Programming
Getting Started With Coding
Presentation transcript:

C – Programming Language Company LOGO C – Programming Language PROF. S. LAKSHMANAN, DEPT. OF B. VOC. (SD & SA), ST. JOSEPH'S COLLEGE.

What does C Programming Language (C) mean? Company LOGO What does C Programming Language (C) mean? C is a high-level and general-purpose programming language It is developing portable application Originally intended for writing system software C was developed at Bell Labs by Dennis Ritchie for the Unix Operating System in the early 1970s.

important features include: Company LOGO important features include: Fixed number of keywords, including a set of control primitives, such as if, for, while, switch and do while Multiple logical and mathematical operators, including bit manipulators Multiple assignments may be applied in a single statement. Function return values are not always required and may be ignored if unneeded. Typing is static. All data has type but may be implicitly converted. It is proven, flexible and powerful used for variety of different applications.

Company LOGO C Program Structure A C program basically consists of the following parts: Preprocessor Commands Functions Variables Statements & Expressions Comments

Simple Program Example: /* Return the hello string in C */ Company LOGO Simple Program Example: /* Return the hello string in C */ /save hello.c #include <stdio.h> // header file int main() // main function { printf("Hello World! \n"); //write the value return 0; // it will return the output value }

Compile & Execute C Program: Company LOGO Compile & Execute C Program: Open turboc and type the program. Press F2 Save the file as hello.c Compile the program using Alt + F9 OR Compile > Compile Press Ctrl + F9 to Run (or select Run > Run in menu bar ) the C program. Alt+F5 to view the output of the program at the output screen. You will be able to see "Hello World!" printed on the screen

Simple Program Example:2 /* Addition of Two Number*/ Company LOGO Simple Program Example:2 /* Addition of Two Number*/ #include <stdio.h> #include <conio.h> void main() { int a,b; clrscr(); printf(“Enter the number a”); scanf(“%d”,&a) scanf(“%d”,&b) printf(“The Addition of (A+B)=%d”,(a+b)); getch() }

Header file Header files serve two purposes. Company LOGO Header file A header file is a file containing C declarations and macro definitions(see Macros) to be shared between several source files. You request the use of a header file in your program by including it, with the C preprocessing directive ' #include '. Header files serve two purposes. System header files declare the interfaces to parts of the operating system. You include them in your program to supply the definitions and declarations you need to invoke system calls and libraries. Your own header files contain declarations for interfaces between the source files of your program.

Input / Output Statement Company LOGO Input / Output Statement Input Statement: SCANF()  Read Syntax: scanf(“control string”,&variable1…&variable n) & Denotes the variable name of address Control string ,argument are separated by commas Example: scanf(“%d’,&a) single value scanf(“%d%d’,&a,&b) muli value

Input / Output Statement Company LOGO Input / Output Statement Output Statement: PRINTF Write Syntax: printf(“control string”, arg1…argn) arg  the arguments contain strored content %wd  miminum value of width(filed width)-%3d,5%d Example: printf(“Hello”); int=10,b=20; printf(“The a vaule=%d, b value=%d”,a,b );

Variable Variable is data name, that will be stored value Company LOGO Variable Variable is data name, that will be stored value The computer will place variables in different locations each time our program is run. It is far more important to us to know what type of data we will be storing in the location.  In programming languages with only two levels of visibility  local variables are contrasted with global variables.

Company LOGO Variable Local variable references in the function or block in which it is declared override the same variable name in the larger scope. Global variable In computer programming, a global variable is a variable with global scope. meaning that it is visible (hence accessible) throughout the program, unless shadowed. The set of all global variables is known as the global environment or global state.

Variable Declaring Rules Company LOGO Variable Declaring Rules The name of a variable can be made of one letter(a-z and A_Z) The name cannot start with a digit. If the name starts with an underscore, the second character must be an alphabetical letter After the first character, the name of the variable can include letters, digits (0, 1, 2, 3, 4, 5, 6, 7, 8, or 9), or underscores in any combination The name of a variable cannot be one of the key words that the  languages has reserved for its own use. A reserved word is also called a keyword.

Company LOGO Variable Keywords: Keywords are the reserved words used in programming. Each keywords has fixed meaning and that cannot be changed by user. For example: int age; Here, int is a keyword that indicates, ‘age' is of type integer.

Data Types and Sizes Type Meaning Size (bytes) Size (bits) char Company LOGO Data Types and Sizes Type Meaning Size (bytes) Size (bits) char a single byte, capable of holding one character 1 byte 8 bits int an integer 4 bytes 32 bits float single-precision floating point number double double-precision floating point number 8 bytes 64 bits

Expressions are evaluated using an assignment statement of the form Company LOGO Expression An expression is a combination of variables, constants and operators written according to the syntax of language. Expressions are evaluated using an assignment statement of the form Syntax: Variable = expression; Example : int X,Y,Z; X=Y+Z+10X,Y,Z is Variable, 10 is constant or operand, += is Operator is Combination is called as Expressions

Company LOGO Thank You.