11/10/2018.

Slides:



Advertisements
Similar presentations
Programming Languages and Paradigms
Advertisements

Programming Languages and Paradigms The C Programming Language.
ITEC113 Algorithms and Programming Techniques
IntroductionIntroduction  Computer program: an ordered sequence of statements whose objective is to accomplish a task.  Programming: process of planning.
True or false A variable of type char can hold the value 301. ( F )
C Programming Basics Lecture 5 Engineering H192 Winter 2005 Lecture 05
CS Data Structures Appendix 1 How to transfer a simple loop- expression to a recursive function (factorial calculation)
1 MATERI PENDUKUNG OPERATOR Matakuliah: M0074/PROGRAMMING II Tahun: 2005 Versi: 1/0.
C Programming Language tutorial Powered by:-
© Janice Regan, CMPT 128, Jan CMPT 128: Introduction to Computing Science for Engineering Students Data representation and Data Types Variables.
ASP.NET Programming with C# and SQL Server First Edition Chapter 3 Using Functions, Methods, and Control Structures.
JAVA Tokens. Introduction A token is an individual element in a program. More than one token can appear in a single line separated by white spaces.
Dennis Ritchie 1972 AT & T Bell laboratories (American Telephone and Telegraph) USA 1www.gowreeswar.com.
Chapters 1-5 Review C++ Class. Chapter 1 – the big picture Objects Class Inheritance Reusability Polymorphism and Overloading.
3. Controlling Program Flow Methods, parameters, and return values Boolean expressions Conditional branching Loops.
VARIABLES, CONSTANTS, OPERATORS ANS EXPRESSION
Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 5P. 1Winter Quarter C Programming Basics Lecture 5.
Control Flow Statements
UMBC CMSC 104 – Section 01, Fall 2016
Objectives In this chapter, you will:
Chapter 12 Variables and Operators
BASIC ELEMENTS OF A COMPUTER PROGRAM
2008/11/19: Lecture 18 CMSC 104, Section 0101 John Y. Park
Chapter 2 - Introduction to C Programming
Programming Languages and Paradigms
Basic Elements of C++.
C Language VIVA Questions with Answers
Learning C Language.
BY GAWARE S.R. COMPUTER SCI. DEPARTMENT
C Short Overview Lembit Jürimägi.
Programming Paradigms
Prepared By: G.UshaRani B.Pranalini A.S.Lalitha
Introduction to C Programming Language
Chapter 2 - Introduction to C Programming
Chapter 8: Control Structures
Programmazione I a.a. 2017/2018.
Introduction to C Programming
Basic Elements of C++ Chapter 2.
Visit for more Learning Resources
Chapter 12 Variables and Operators
Instructions - Type and Format
Starting JavaProgramming
Chapter 2 - Introduction to C Programming
Chapter 2 - Introduction to C Programming
Character Set The character set of C represents alphabet, digit or any symbol used to represent information. Types Character Set Uppercase Alphabets A,
Java - Data Types, Variables, and Arrays
Basics of ‘C’.
Chapter 2 - Introduction to C Programming
Structured Program
Chapter 4 - Program Control
Introduction to C Programming
PHP.
C Operators, Operands, Expressions & Statements
Flow of Control.
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.
Govt. Polytechnic,Dhangar
Chapter 2 - Introduction to C Programming
Lecture3.
C Programming Getting started Variables Basic C operators Conditionals
C programming Language
Chapter 2 - Introduction to C Programming
Module 2 Variables, Data Types and Arithmetic
Programming Languages and Paradigms
2008/11/19: Lecture 18 CMSC 104, Section 0101 John Y. Park
C Language B. DHIVYA 17PCA140 II MCA.
Course Outcomes of Programming In C (PIC) (17212, C203):
Introduction to C Programming
INTRODUCTION TO C.
Chapter 12 Variables and Operators
Presentation transcript:

11/10/2018

Unit I Introduction to C Contents : Operators ,control structures, enumeration ,structure , union, macros , arrays ,functions and parameter passing in C ,scope rules , string manipulation , matrix operations. Objective : To understand the basic building blocks of C language. To make the student comfortable in understanding the structure of the language. To inspire the students for simple problem solving and inculcating problem tackling skills 11/10/2018

Introduction to C Operators Functions and parameter passing in C control structures Enumeration Structure Union Macros Functions and parameter passing in C Arrays Scope rules String manipulation , 11/10/2018

Introduction to C Motivation behind computers It is an electronic machine Alan Turing's shorthand codes Developed by Dennis Ritchie Flexible in nature Procedure oriented language Follows top down approach 11/10/2018

Operators in C Operators and Operands Operators are the special symbols which are used to indicate the type of operation operands are the data member or variables operating as per operation specified by operator. One expression contains set operators and operands There are six types of operator 11/10/2018

Arithmetic Operator operators which are useful in performing mathematical calculations. + : Used to add two operands - : Used to subtract two operands *: Used to multiply two operands /: Used to divide two operands %: Find reminder of the division of two operand To understand the operation assume variable A contains value 10 and variable contains value 5. 11/10/2018

Arithmetic Operator 11/10/2018

Relational Operator operators which are useful in performing mathematical calculations. <  > : < =: >=: ==: !=: To understand the operation assume variable A contains value 10 and variable contains value 5. 11/10/2018

Relational Operator 11/10/2018

Logical Operator operators which are useful in performing mathematical calculations. && : This is logical AND, it returns true when both the values are non zero ||: This is logical OR, it returns true when any of two value is non zero !: This is logical NOT operator, it is used to reverse the logical state of operand To understand the operation assume variable A contains value 10 and variable contains value 5. 11/10/2018

Logical Operator 11/10/2018

Other Operators Assignment Operators Increments and Decrement Operators Bitwise Operators: work on the binary data. & | ^ To understand the operation assume variable A contains value 10 and variable contains value 5. 11/10/2018

Bitwise Operators 11/10/2018

Control Structures in C Responsible to determine the sequence of other instructions in the program and for the reusability of the code Conditional Branching: if-----else statement switch statement Unconditional Branching: Break statement Goto statement: Continue statement Return statement 11/10/2018

Conditional Branching 11/10/2018

Control Structures in C Responsible to determine the sequence of other instructions in the program and for the reusability of the code Conditional Branching: if-----else statement switch statement Unconditional Branching: Break statement Goto statement: Continue statement Return statement 11/10/2018

if-----else statement: if (condition)           statement1           statement2 if-----else statement: if (condition) statement1; else statement2; 11/10/2018

switch statements: switch(expression) { case constant1: statements 1; break; case constant2: statements 2; ………………….. default: statements n; }   11/10/2018

Unconditional Branching Break statement: transfer the flow of program outside the loop or “switch” statement break; Goto statement: transfer the flow of program to any part of program           goto label name; label name : statement Continue statement: flow of program to the loop control instruction. Return statement : terminates the execution of the current function and return control to the calling function. 11/10/2018

Enumeration in C language ‘act of counting’ defined by using keyword ‘enum’ By default indexing of enumeration starts with ‘0’ enum identifier {enumerator list}; enum identifier object-name; 11/10/2018

Structures in C language ‘user define data type struct structure_name { structure element1; : :….. }; 11/10/2018

union in C language ‘user define data type union union _name { union element1; : :….. }; 11/10/2018

Macros in C language ‘Macro represents the majorly used instruction in the program’ Macros are expanded by the C preprocessor. # define symbolic-name constant Example: # define pi 3.14 11/10/2018

Arrays in C language: Array is a data structure which stores the collection of similar types of element Indexing of array always start with ‘0’ data type array name[Maximum size]; 11/10/2018

Control Structures in C Responsible to determine the sequence of other instructions in the program and for the reusability of the code Conditional Branching: if-----else statement switch statement Unconditional Branching: Break statement Goto statement: Continue statement Return statement 11/10/2018

Functions And Parameter Passing In C language: block of code which is used to perform a specific task Functions are useful to divide c programs into smaller modules. function definition present outside the main function Return Type Function name (Argument list) { Statement 1; Statement 2; …………... Statement n; } 11/10/2018

Parameter passing by value: : #include <stdio.h> #include<conio.h> /* function declaration goes here.*/ void swap( int p1, int p2 ); int main() { int a = 10; int b = 20; printf("Before: Value of a = %d and value of b = %d\n", a, b ); swap( a, b ); printf("After: Value of a = %d and value of b = %d\n", a, b ); getch(); }   11/10/2018

Parameter passing by value: void swap( int p1, int p2 ) { int t; t = p2; p2 = p1; p1 = t; printf("Value of a (p1) = %d and value of b(p2) = %d\n", p1, p2 ); } Output : Before: Value of a = 10 and value of b = 20 Value of a (p1) = 20 and value of b (p2) = 10 After: Value of a = 10 and value of b = 20 11/10/2018

Parameter passing by reference: : #include <stdio.h> #include<conio.h> /* function declaration goes here.*/ void swap( int p1, int p2 ); int main() { int a = 10; int b = 20; printf("Before: Value of a = %d and value of b = %d\n", a, b ); swap( a, b ); printf("After: Value of a = %d and value of b = %d\n", a, b ); getch(); } 11/10/2018

Parameter passing by reference: : void swap( int *p1, int *p2 ) { int t; t = *p2; *p2 = *p1; *p1 = t; printf("Value of a (p1) = %d and value of b(p2) = %d\n", *p1, *p2 ); }  Output :  Before: Value of a = 10 and value of b = 20 Value of a (p1) = 20 and value of b(p2) = 10 After: Value of a = 20 and value of b = 10   11/10/2018

String Manipulation in C language: Strings are also called as the array of character. A special character usually known as null character (\0) is used to indicate the end of the string. To read and write the string in C program %s access specifier is required. 11/10/2018

String Manipulation in C language: 11/10/2018