C Programming Language tutorial Powered by:-www.javatpoint.com.

Slides:



Advertisements
Similar presentations
Introduction to C Programming
Advertisements

C Language.
11-2 Identify the parts of the “main” function, which include Preprocessor Directives main function header main function body which includes Declaration.
5/17/ Programming Constructs... There are several types of programming constructs in JAVA. - If-else construct or ternary operator - while - do-while.
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 ICS103 Programming in C Lecture 2: Introduction to C (1)
COMP1170 Midterm Preparation (March 17 th 2009) Acknowledgment The notes are adapted from those provided by Deitel & Associates, Inc. and Pearson Education.
C programming Language and Data Structure For DIT Students.
UNIT II Decision Making And Branching Decision Making And Looping
 Introduction Introduction  Types of Function Types of Function  Library function Library function  User defined function User defined function 
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.
Introduction to Computer Algorithmics and Programming Ceng 113 Variables and Operators in C.
Basics of “C” Programming
By Sidhant Garg.  C was developed between by Dennis Ritchie at Bell Laboratories for use with the Unix Operating System.  Unlike previously.
Lecture 10: Reviews. Control Structures All C programs written in term of 3 control structures Sequence structures Programs executed sequentially by default.
C Programming n General Information on C n Data Types n Arithmetic Operators n Relational Operators n if, if-else, for, while by Kulapan Waranyuwat.
Hello.java Program Output 1 public class Hello { 2 public static void main( String [] args ) 3 { 4 System.out.println( “Hello!" ); 5 } // end method main.
C STRUCTURES. A FIRST C PROGRAM  #include  void main ( void )  { float height, width, area, wood_length ;  scanf ( "%f", &height ) ;  scanf ( "%f",
C Programming language Basic Concepts Prepared By The Smartpath Information systems
CECS 121 Test 1. Functions allow you to group program statements under one name C and C++ are case-sensitive so main(), MAIN(), and Main() are all different.
Dennis Ritchie 1972 AT & T Bell laboratories (American Telephone and Telegraph) USA 1www.gowreeswar.com.
Data Structure and c K.S.Prabhu Lecturer All Deaf Educational Technology.
Chapter 15 JavaScript: Part III The Web Warrior Guide to Web Design Technologies.
Slides created by: Professor Ian G. Harris Hello World #include main() { printf(“Hello, world.\n”); }  #include is a compiler directive to include (concatenate)
Loops cause a section of a program to be repeated a certain number of times. The repetition continues while a condition remains true. When a condition.
Lecture 15: Course Review BJ Furman ME 30 16MAY2011.
Chapter 1 Java Programming Review. Introduction Java is platform-independent, meaning that you can write a program once and run it anywhere. Java programs.
Introduction to C programming. History of C programming Invented and Developed by Dennis Ritchie and Brian Kernighan at Bell Laboratories in 1972 Predecessor.
Session 2 Operators, Decisions and Loops. Objectives Operators Casting data Decision marking structures Loops break, continue, return.
Java Basics. Tokens: 1.Keywords int test12 = 10, i; int TEst12 = 20; Int keyword is used to declare integer variables All Key words are lower case java.
Sudeshna Sarkar, IIT Kharagpur 1 Programming and Data Structure Sudeshna Sarkar Lecture 3.
Today… Preparation for doing Assignment 1. Invoking methods overview. Conditionals and Loops. Winter 2016CMPE212 - Prof. McLeod1.
BASIC C PROGRAMMING LANGUAGE TUTORIAL infobizzs.com.
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.
Module 6 – Decision Control Statements Objectives  Understands Increment/Decrement operators, Conditional and special operators in C  Understands significance.
BY ILTAF MEHDI(MCS,MCSE, CCNA) 1. INSTRUCTOR: ILTAF MEHDI (MCS, MCSE, CCNA, Web Developer) BY ILTAF MEHDI(MCS,MCSE, CCNA) 2 Programming Fundamentals Chapter.
Prof: Dr. Shu-Ching Chen TA: Samira Pouyanfar Spring 2017
C Interview Questions Prepared By:.
A bit of C programming Lecture 3 Uli Raich.
INC 161 , CPE 100 Computer Programming
Decisions Chapter 4.
C Language VIVA Questions with Answers
Learning C Language.
Overview of C.
C Fundamentals & Pointers
Prof: Dr. Shu-Ching Chen TA: Samira Pouyanfar Hector Cen Fall 2017
BY GAWARE S.R. COMPUTER SCI. DEPARTMENT
Prepared By: G.UshaRani B.Pranalini A.S.Lalitha
Introduction to C Programming Language
Visit for more Learning Resources
11/10/2018.
Computer Science 210 Computer Organization
Arrays, For loop While loop Do while loop
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.
Govt. Polytechnic,Dhangar
C Programming Getting started Variables Basic C operators Conditionals
C programming Language
In C Programming Language
C ( Programming Language ) PSK Technologies By: Arti Sontakke An ISO 9001:2015 (QMS) Certified IT Company Computer Education | Software Development | Computer.
Fundamental Programming
The C Language: Intro.
C – Programming Language
Programming Languages and Paradigms
C Language B. DHIVYA 17PCA140 II MCA.
Course Outcomes of Programming In C (PIC) (17212, C203):
Getting Started With Coding
Presentation transcript:

C Programming Language tutorial Powered by:-

What is c language:-  C is mother language of all programming language.  It is system programming language.  It is procedure-oriented programming language.  It is also called mid level programming language.

History of c language:-  C programming language was developed in 1972 by Dennis Ritchie at bell laboratories of AT&T(American Telephone & Telegraph), located in U.S.A.  Dennis Ritchie is known as founder of c language.  It was developed to be used in UNIX Operating system.  It inherits many features of previous languages such as B and BPCL.

LanguageyearDeveloped By ALGOL1960International Group BPCL1967Martin Richards B1970Ken Thompson Traditional C1972Dennis Ritchie K & R C1978Kernighan & Dennis Ritchie ANSI C 1989ANSI Committee ANSI/ISO C1990ISO Committee C991999Standardization Committee

Features of C Language:- There are many features of c language are given below. 1) Simple 2) Machine Independent or Portable 3) Mid-level programming language 4) structured programming language 5) Rich Library 6) Memory Management 7) Fast Speed 8) Pointers 9) Recursion 10) Extensible

First Program of C Language:- #include void main(){ printf("Hello C Language"); getch(); }

Describe the C Program:-  #include includes the standard input output library functions. The printf() function is defined in stdio.h.  #include includes the console input output library functions. The getch() function is defined in conio.h file.  void main() The main() function is the entry point of every program in c language. The void keyword specifies that it returns no value.  printf() The printf() function is used to print data on the console.  getch() The getch() function asks for a single character. Until you press any key, it blocks the screen.

Output of Program is:- Hello C Language

Input output function:-  There are two input output function of c language. 1) First is printf() 2) Second is scanf()  printf() function is used for output. It prints the given statement to the console.  Syntax of printf() is given below:  printf(“format string”,arguments_list);  Format string can be %d(integer), %c(character), %s(string), %f(float) etc.

 scanf() Function: is used for input. It reads the input data from console.  scanf(“format string”,argument_list); Note:-See more example of input-output function on:- scanf

Data types in C language:-  There are four types of data types in C language. TypesData Types Basic Data Typeint, char, float, double Derived Data Typearray, pointer, structure, union Enumeration Data Typeenum Void Data Typevoid

Keywords in C Language:-  A keyword is a reserved word. You cannot use it as a variable name, constant name etc.  There are 32 keywords in C language as given below: autobreakcasecharconstcontinu e defaultdo doubleelseenumexternfloatforgotoif intlongregisterreturnshortsignedsizeofstatic structswitchtypedefunionunsignedvoidvolatilewhile

Operators in C language:-  There are following types of operators to perform different types of operations in C language. 1) Arithmetic Operators 2) Relational Operators 3) Shift Operators 4) Logical Operators 5) Bitwise Operators 6) Ternary or Conditional Operators 7) Assignment Operator 8) Misc Operator

Control statement in C language:- 1) if-else 2) switch 3) loops 4) do-while loop 5) while loop 6) for loop 7) break 8) continue

C if else statement:-  There are many ways to use if statement in C language: 1) If statement 2) If-else statement 3) If else-if ladder 4) Nested if

if statement:-  In if statement is used to execute the code if condition is true.  syntax:- if(expression){ //code to be execute }

If else statement:-  The if-else statement is used to execute the code if condition is true or false.  Syntax: if(expression){ //code to be executed if condition is true }else{ //code to be executed if condition is false }

If else-if ladder Statement:- The if else-if statement is used to execute one code from multiple conditions. Syntax: if(condition1){ //code to be executed if condition1 is true }else if(condition2){ //code to be executed if condition2 is true } else if(condition3){ //code to be executed if condition3 is true }... else{ //code to be executed if all the conditions are false }

if else-if ladder Statement:-  Syntax: if(condition1){ //code to be executed if condition1 is true }else if(condition2){ //code to be executed if condition2 is true } else if(condition3){ //code to be executed if condition3 is true }... else{ //code to be executed if all the conditions are false }

C Switch Statement:-  Syntax: switch(expression){ case value1: //code to be executed; break; //optional case value2: //code to be executed; break; //optional default: code to be executed if all cases are not matched; }

Loops in C language:-  Loops are used to execute a block of code or a part of program of the program several times. Types of loops in C language:-  There are 3 types of loops in c language. 1) do while 2) while 3) for

do-while loop in C:-  It is better if you have to execute the code at least once.  Syntax:- do{ //code to be executed }while(condition);

while loop in c language:-  It is better if number of iteration is not known by the user.  Syntax:- while(condition){ //code to be executed }

For loop in C language:-  It is good if number of iteration is known by the user.  Syntax:- for(initialization;condition;incr/decr){ //code to be executed }

C break statement:-  it is used to break the execution of loop (while, do while and for) and switch case.  Syntax:- jump-statement; break;

Continue statement in C language:-  it is used to continue the execution of loop (while, do while and for). It is used with if condition within the loop.  Syntax:- jump-statement; continue; Note:- you can see the example of above all control statements on else. else

Functions in C language:-  To perform any task, we can create function. A function can be called many times. It provides modularity and code reusability. Advantage of function:- 1) Code Resuability 2) Code optimization

 Syntax to declare function:- return_type function_name(data_type para meter...){ //code to be executed }  Syntax to call function:- variable=function_name(arguments...);

Call by value in C language:- In call by value, value being passed to the function is locally stored by the function parameter in stack memory location. If you change the value of function parameter, it is changed for the current function only. It will not change the value of variable inside the caller method such as main().

Example of call by value:- #include void change(int num) { printf("Before adding value inside function num=%d \n",num); num=num+100; printf("After adding value inside function num=%d \n", num); } int main() { int x=100; clrscr(); printf("Before function call x=%d \n", x); change(x);//passing value in function printf("After function call x=%d \n", x); getch(); return 0; }

Output:-  Before function call x=100  Before adding value inside function num=100  After adding value inside function num=200  After function call x=100

Call by reference in C:-  In call by reference, original value is modified because we pass reference (address).

Example of call by Reference:- #include void change(int *num) { printf("Before adding value inside function num=%d \n",*num); (*num) += 100; printf("After adding value inside function num=%d \n", *num); } int main() { int x=100; clrscr(); printf("Before function call x=%d \n", x); change(&x);//passing reference in function printf("After function call x=%d \n", x); getch(); return 0; }

Output:-  Before function call x=100  Before adding value inside function num=100  After adding value inside function num=200  After function call x=200

Recursion in C:-  A function that calls itself, and doen't perform any task after function call, is know as tail recursion. In tail recursion, we generally call the same function with return statement.  Syntax:- recursionfunction(){ recursionfunction();//calling self function }

Array in C:-  Array in C language is a collection or group of elements (data). All the elements of array are homogeneous(similar). It has contiguous memory location. Declaration of array:-  data_type array_name[array_size]; Eg:-  int marks[7]; Types of array:- 1) 1-D Array 2) 2-D Array

Advantage of array:- 1) Code Optimization 2) Easy to traverse data 3) Easy to sort data 4) Random Access

2-D Array in C:-  2-d Array is represented in the form of rows and columns, also known as matrix. It is also known as array of arrays or list of arrays. Declaration of 2-d array:-  data_type array_name[size1][size2];

Initialization of 2-d array:-  int arr[3][4]={{1,2,3,4},{2,3,4,5},{3,4, 5,6}};