SlideShare a Scribd company logo
1 of 45
Submitted By :- Ass.Pro.Amol Chavan
Department of computer science
What is c language:-
C is mother language of all programming
language.
It is a popular computer 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.
History of c programming
Language year Developed By
ALGOL 1960 International Group
BPCL 1967 Martin Richards
B 1970 Ken Thompson
Traditional C 1972 Dennis Ritchie
K & R C 1978 Kernighan & Dennis
Ritchie
ANSI C 1989 ANSI Committee
ANSI/ISO C 1990 ISO Committee
C99 1999 Standardization
Committee
Features of C Language:-
There are many features of c language are given below.
1) Machine Independent or Portable
2) Mid-level programming language
3) structured programming language
4) Rich Library
5) Memory Management
6) Fast Speed
7) Pointers
8) Recursion
9) Extensible
First Program of C Language:-
#include <stdio.h>
#include <conio.h>
void main(){
printf(“welcome to technical
world”);
getch();
}
Describe the C Program :-
 #include <stdio.h> includes the standard input
output library functions. The printf() function is
defined in stdio.h .
 #include <conio.h> 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:-
welcome to
technical world
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.
Input/ output function
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:-
 www.javatpoint.com/printf-scanf
Data types in C language:-
There are four types of data types in C
language.
Types Data Types
Basic Data Type int, char, float, double
Derived Data Type array, pointer, structure, union
Enumeration Data Type enum
Void Data Type void
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:
auto break case char const contin
ue
default do
double else enum extern float for goto if
int long register return short signed sizeof static
struct switch typedef union unsigned void volatile while
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:-
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. www.javatpoint.com/c-
if 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 parameter.
..){
//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 <stdio.h>
#include <conio.h>
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 window :-
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).
Note : Learn Call by reference in details with
example via JavaTpoint.
Example of call by Reference:-
#include <stdio.h>
#include <conio.h>
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 window:-
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}};
C1 C2 C3 C4
R1
R2
R3
1 2 3 4
2 3 4 5
3 4 5 6
Pointer in c language
 Pointer is a user defined data_type which create the
special types of variables.
 It can hold the address of primitive data type like int,
char, float, double or user define datatypes like
function, pointer etc.
 it is used to retrieving strings, trees etc. and used with
arrays, structures and functions.
Advantage of pointer in c
 Pointer reduces the code and improves the
performance.
 We can return multiple values from function using
pointer.
 It make you able to access any memory location in the
computer’s memory.
symbol used in pointer
Symbol Name Description
& (ampersand
sign)
address of operator determines the
address of a
variable.
* (asterisk sign) indirection operator accesses the value
at the address.
Declaration of pointerSyntax:-
int *ptr;
int (*ptr)();
int (*ptr)[2];
For e.g.-
int a=5; // a= variable name//
int * ptr; // value of variable= 5//
ptr=&a; // Address where it has stored in
memory : 1025 (assume) //
A simple example of C pointer
#include <stdio.h>
#include <conio.h>
void main(){
int number=50;
clrscr();
printf("value of number is %d, address o
f number is %u",number,&number);
getch();
}
Output window
Introduction to c

More Related Content

What's hot

Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programming
ABHISHEK fulwadhwa
 

What's hot (20)

Introduction to C programming
Introduction to C programmingIntroduction to C programming
Introduction to C programming
 
Introduction to C Programming
Introduction to C ProgrammingIntroduction to C Programming
Introduction to C Programming
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programming
 
C programming tutorial for beginners
C programming tutorial for beginnersC programming tutorial for beginners
C programming tutorial for beginners
 
Programming in C Basics
Programming in C BasicsProgramming in C Basics
Programming in C Basics
 
The smartpath information systems c pro
The smartpath information systems c proThe smartpath information systems c pro
The smartpath information systems c pro
 
A brief introduction to C Language
A brief introduction to C LanguageA brief introduction to C Language
A brief introduction to C Language
 
C programming basics
C  programming basicsC  programming basics
C programming basics
 
C PROGRAMMING
C PROGRAMMINGC PROGRAMMING
C PROGRAMMING
 
Introduction to C Programming
Introduction to C ProgrammingIntroduction to C Programming
Introduction to C Programming
 
C tutorial
C tutorialC tutorial
C tutorial
 
C language introduction
C language introduction C language introduction
C language introduction
 
C basics
C   basicsC   basics
C basics
 
Advanced C Language for Engineering
Advanced C Language for EngineeringAdvanced C Language for Engineering
Advanced C Language for Engineering
 
Unit 4 Foc
Unit 4 FocUnit 4 Foc
Unit 4 Foc
 
C Programming Language Tutorial for beginners - JavaTpoint
C Programming Language Tutorial for beginners - JavaTpointC Programming Language Tutorial for beginners - JavaTpoint
C Programming Language Tutorial for beginners - JavaTpoint
 
Introduction to C Programming - I
Introduction to C Programming - I Introduction to C Programming - I
Introduction to C Programming - I
 
Learning the C Language
Learning the C LanguageLearning the C Language
Learning the C Language
 
C languaGE UNIT-1
C languaGE UNIT-1C languaGE UNIT-1
C languaGE UNIT-1
 
C program
C programC program
C program
 

Similar to Introduction to c

C programming session 01
C programming session 01C programming session 01
C programming session 01
Dushmanta Nath
 
C notes.pdf
C notes.pdfC notes.pdf
C notes.pdf
Durga Padma
 
C Programming ppt for beginners . Introduction
C Programming ppt for beginners . IntroductionC Programming ppt for beginners . Introduction
C Programming ppt for beginners . Introduction
raghukatagall2
 

Similar to Introduction to c (20)

C programming language tutorial
C programming language tutorial C programming language tutorial
C programming language tutorial
 
C programming session 01
C programming session 01C programming session 01
C programming session 01
 
Theory1&amp;2
Theory1&amp;2Theory1&amp;2
Theory1&amp;2
 
Complete c programming presentation
Complete c programming presentationComplete c programming presentation
Complete c programming presentation
 
C notes.pdf
C notes.pdfC notes.pdf
C notes.pdf
 
Introduction to C Unit 1
Introduction to C Unit 1Introduction to C Unit 1
Introduction to C Unit 1
 
Let's us c language (sabeel Bugti)
Let's us c language (sabeel Bugti)Let's us c language (sabeel Bugti)
Let's us c language (sabeel Bugti)
 
Presentation 2.ppt
Presentation 2.pptPresentation 2.ppt
Presentation 2.ppt
 
venkatesh.pptx
venkatesh.pptxvenkatesh.pptx
venkatesh.pptx
 
C_Programming_Language_tutorial__Autosaved_.pptx
C_Programming_Language_tutorial__Autosaved_.pptxC_Programming_Language_tutorial__Autosaved_.pptx
C_Programming_Language_tutorial__Autosaved_.pptx
 
Structures-2
Structures-2Structures-2
Structures-2
 
C Programming ppt for beginners . Introduction
C Programming ppt for beginners . IntroductionC Programming ppt for beginners . Introduction
C Programming ppt for beginners . Introduction
 
Unit1 C
Unit1 CUnit1 C
Unit1 C
 
Unit1 C
Unit1 CUnit1 C
Unit1 C
 
c_pro_introduction.pptx
c_pro_introduction.pptxc_pro_introduction.pptx
c_pro_introduction.pptx
 
C notes for exam preparation
C notes for exam preparationC notes for exam preparation
C notes for exam preparation
 
Unit 1 c - all topics
Unit 1   c - all topicsUnit 1   c - all topics
Unit 1 c - all topics
 
Csdfsadf
CsdfsadfCsdfsadf
Csdfsadf
 
C
CC
C
 
C
CC
C
 

Recently uploaded

PODOCARPUS...........................pptx
PODOCARPUS...........................pptxPODOCARPUS...........................pptx
PODOCARPUS...........................pptx
Cherry
 
CYTOGENETIC MAP................ ppt.pptx
CYTOGENETIC MAP................ ppt.pptxCYTOGENETIC MAP................ ppt.pptx
CYTOGENETIC MAP................ ppt.pptx
Cherry
 
LUNULARIA -features, morphology, anatomy ,reproduction etc.
LUNULARIA -features, morphology, anatomy ,reproduction etc.LUNULARIA -features, morphology, anatomy ,reproduction etc.
LUNULARIA -features, morphology, anatomy ,reproduction etc.
Cherry
 
Porella : features, morphology, anatomy, reproduction etc.
Porella : features, morphology, anatomy, reproduction etc.Porella : features, morphology, anatomy, reproduction etc.
Porella : features, morphology, anatomy, reproduction etc.
Cherry
 
POGONATUM : morphology, anatomy, reproduction etc.
POGONATUM : morphology, anatomy, reproduction etc.POGONATUM : morphology, anatomy, reproduction etc.
POGONATUM : morphology, anatomy, reproduction etc.
Cherry
 

Recently uploaded (20)

Climate Change Impacts on Terrestrial and Aquatic Ecosystems.pptx
Climate Change Impacts on Terrestrial and Aquatic Ecosystems.pptxClimate Change Impacts on Terrestrial and Aquatic Ecosystems.pptx
Climate Change Impacts on Terrestrial and Aquatic Ecosystems.pptx
 
ABHISHEK ANTIBIOTICS PPT MICROBIOLOGY // USES OF ANTIOBIOTICS TYPES OF ANTIB...
ABHISHEK ANTIBIOTICS PPT MICROBIOLOGY  // USES OF ANTIOBIOTICS TYPES OF ANTIB...ABHISHEK ANTIBIOTICS PPT MICROBIOLOGY  // USES OF ANTIOBIOTICS TYPES OF ANTIB...
ABHISHEK ANTIBIOTICS PPT MICROBIOLOGY // USES OF ANTIOBIOTICS TYPES OF ANTIB...
 
PODOCARPUS...........................pptx
PODOCARPUS...........................pptxPODOCARPUS...........................pptx
PODOCARPUS...........................pptx
 
CYTOGENETIC MAP................ ppt.pptx
CYTOGENETIC MAP................ ppt.pptxCYTOGENETIC MAP................ ppt.pptx
CYTOGENETIC MAP................ ppt.pptx
 
FS P2 COMBO MSTA LAST PUSH past exam papers.
FS P2 COMBO MSTA LAST PUSH past exam papers.FS P2 COMBO MSTA LAST PUSH past exam papers.
FS P2 COMBO MSTA LAST PUSH past exam papers.
 
Kanchipuram Escorts 🥰 8617370543 Call Girls Offer VIP Hot Girls
Kanchipuram Escorts 🥰 8617370543 Call Girls Offer VIP Hot GirlsKanchipuram Escorts 🥰 8617370543 Call Girls Offer VIP Hot Girls
Kanchipuram Escorts 🥰 8617370543 Call Girls Offer VIP Hot Girls
 
LUNULARIA -features, morphology, anatomy ,reproduction etc.
LUNULARIA -features, morphology, anatomy ,reproduction etc.LUNULARIA -features, morphology, anatomy ,reproduction etc.
LUNULARIA -features, morphology, anatomy ,reproduction etc.
 
TransientOffsetin14CAftertheCarringtonEventRecordedbyPolarTreeRings
TransientOffsetin14CAftertheCarringtonEventRecordedbyPolarTreeRingsTransientOffsetin14CAftertheCarringtonEventRecordedbyPolarTreeRings
TransientOffsetin14CAftertheCarringtonEventRecordedbyPolarTreeRings
 
Call Girls Ahmedabad +917728919243 call me Independent Escort Service
Call Girls Ahmedabad +917728919243 call me Independent Escort ServiceCall Girls Ahmedabad +917728919243 call me Independent Escort Service
Call Girls Ahmedabad +917728919243 call me Independent Escort Service
 
FAIRSpectra - Enabling the FAIRification of Spectroscopy and Spectrometry
FAIRSpectra - Enabling the FAIRification of Spectroscopy and SpectrometryFAIRSpectra - Enabling the FAIRification of Spectroscopy and Spectrometry
FAIRSpectra - Enabling the FAIRification of Spectroscopy and Spectrometry
 
PATNA CALL GIRLS 8617370543 LOW PRICE ESCORT SERVICE
PATNA CALL GIRLS 8617370543 LOW PRICE ESCORT SERVICEPATNA CALL GIRLS 8617370543 LOW PRICE ESCORT SERVICE
PATNA CALL GIRLS 8617370543 LOW PRICE ESCORT SERVICE
 
Porella : features, morphology, anatomy, reproduction etc.
Porella : features, morphology, anatomy, reproduction etc.Porella : features, morphology, anatomy, reproduction etc.
Porella : features, morphology, anatomy, reproduction etc.
 
Cyanide resistant respiration pathway.pptx
Cyanide resistant respiration pathway.pptxCyanide resistant respiration pathway.pptx
Cyanide resistant respiration pathway.pptx
 
GBSN - Biochemistry (Unit 2) Basic concept of organic chemistry
GBSN - Biochemistry (Unit 2) Basic concept of organic chemistry GBSN - Biochemistry (Unit 2) Basic concept of organic chemistry
GBSN - Biochemistry (Unit 2) Basic concept of organic chemistry
 
Thyroid Physiology_Dr.E. Muralinath_ Associate Professor
Thyroid Physiology_Dr.E. Muralinath_ Associate ProfessorThyroid Physiology_Dr.E. Muralinath_ Associate Professor
Thyroid Physiology_Dr.E. Muralinath_ Associate Professor
 
Dr. E. Muralinath_ Blood indices_clinical aspects
Dr. E. Muralinath_ Blood indices_clinical  aspectsDr. E. Muralinath_ Blood indices_clinical  aspects
Dr. E. Muralinath_ Blood indices_clinical aspects
 
Gwalior ❤CALL GIRL 84099*07087 ❤CALL GIRLS IN Gwalior ESCORT SERVICE❤CALL GIRL
Gwalior ❤CALL GIRL 84099*07087 ❤CALL GIRLS IN Gwalior ESCORT SERVICE❤CALL GIRLGwalior ❤CALL GIRL 84099*07087 ❤CALL GIRLS IN Gwalior ESCORT SERVICE❤CALL GIRL
Gwalior ❤CALL GIRL 84099*07087 ❤CALL GIRLS IN Gwalior ESCORT SERVICE❤CALL GIRL
 
POGONATUM : morphology, anatomy, reproduction etc.
POGONATUM : morphology, anatomy, reproduction etc.POGONATUM : morphology, anatomy, reproduction etc.
POGONATUM : morphology, anatomy, reproduction etc.
 
Terpineol and it's characterization pptx
Terpineol and it's characterization pptxTerpineol and it's characterization pptx
Terpineol and it's characterization pptx
 
Efficient spin-up of Earth System Models usingsequence acceleration
Efficient spin-up of Earth System Models usingsequence accelerationEfficient spin-up of Earth System Models usingsequence acceleration
Efficient spin-up of Earth System Models usingsequence acceleration
 

Introduction to c

  • 1. Submitted By :- Ass.Pro.Amol Chavan Department of computer science
  • 2. What is c language:- C is mother language of all programming language. It is a popular computer programming language. It is procedure-oriented programming language. It is also called mid level programming language.
  • 3. 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.
  • 4. History of c programming Language year Developed By ALGOL 1960 International Group BPCL 1967 Martin Richards B 1970 Ken Thompson Traditional C 1972 Dennis Ritchie K & R C 1978 Kernighan & Dennis Ritchie ANSI C 1989 ANSI Committee ANSI/ISO C 1990 ISO Committee C99 1999 Standardization Committee
  • 5. Features of C Language:- There are many features of c language are given below. 1) Machine Independent or Portable 2) Mid-level programming language 3) structured programming language 4) Rich Library 5) Memory Management 6) Fast Speed 7) Pointers 8) Recursion 9) Extensible
  • 6. First Program of C Language:- #include <stdio.h> #include <conio.h> void main(){ printf(“welcome to technical world”); getch(); }
  • 7. Describe the C Program :-  #include <stdio.h> includes the standard input output library functions. The printf() function is defined in stdio.h .  #include <conio.h> 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.
  • 8. Output of Program is:- welcome to technical world
  • 9. 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.
  • 10. Input/ output function 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:-  www.javatpoint.com/printf-scanf
  • 11. Data types in C language:- There are four types of data types in C language. Types Data Types Basic Data Type int, char, float, double Derived Data Type array, pointer, structure, union Enumeration Data Type enum Void Data Type void
  • 12. 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: auto break case char const contin ue default do double else enum extern float for goto if int long register return short signed sizeof static struct switch typedef union unsigned void volatile while
  • 13. 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
  • 14. 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
  • 15. 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
  • 16. if statement:- In if statement is used to execute the code if condition is true. syntax:- if(expression){ //code to be execute }
  • 17. 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 }
  • 18. 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 }
  • 19. 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; }
  • 20. 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
  • 21. 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);
  • 22. 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 }
  • 23. 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 }
  • 24. C break statement:-  it is used to break the execution of loop (while, do while and for) and switch case. Syntax:- jump-statement; break;
  • 25. 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. www.javatpoint.com/c- if else
  • 26. 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
  • 27. Syntax to declare function:- return_type function_name(data_type parameter. ..){ //code to be executed } Syntax to call function:- variable=function_name(arguments...);
  • 28. 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().
  • 29. Example of call by value:- #include <stdio.h> #include <conio.h> 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; }
  • 30. Output window :- Before function call x=100 Before adding value inside function num=100 After adding value inside function num=200 After function call x=100
  • 31. Call by reference in C:- In call by reference, original value is modified because we pass reference (address). Note : Learn Call by reference in details with example via JavaTpoint.
  • 32. Example of call by Reference:- #include <stdio.h> #include <conio.h> 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; }
  • 33. Output window:- Before function call x=100 Before adding value inside function num=100 After adding value inside function num=200 After function call x=200
  • 34. 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 }
  • 35. 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
  • 36. Advantage of array:- 1) Code Optimization 2) Easy to traverse data 3) Easy to sort data 4) Random Access
  • 37. 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];
  • 38. Initialization of 2-d array:- int arr[3][4]={{1,2,3,4},{2,3,4,5},{3,4,5,6}}; C1 C2 C3 C4 R1 R2 R3 1 2 3 4 2 3 4 5 3 4 5 6
  • 39. Pointer in c language  Pointer is a user defined data_type which create the special types of variables.  It can hold the address of primitive data type like int, char, float, double or user define datatypes like function, pointer etc.  it is used to retrieving strings, trees etc. and used with arrays, structures and functions.
  • 40. Advantage of pointer in c  Pointer reduces the code and improves the performance.  We can return multiple values from function using pointer.  It make you able to access any memory location in the computer’s memory.
  • 41. symbol used in pointer Symbol Name Description & (ampersand sign) address of operator determines the address of a variable. * (asterisk sign) indirection operator accesses the value at the address.
  • 42. Declaration of pointerSyntax:- int *ptr; int (*ptr)(); int (*ptr)[2]; For e.g.- int a=5; // a= variable name// int * ptr; // value of variable= 5// ptr=&a; // Address where it has stored in memory : 1025 (assume) //
  • 43. A simple example of C pointer #include <stdio.h> #include <conio.h> void main(){ int number=50; clrscr(); printf("value of number is %d, address o f number is %u",number,&number); getch(); }