SlideShare a Scribd company logo
1 of 45
C language
- Priya Patel
Index
2
Page----4
1. Introduction of c
Page----9
2. Datatype, constant
and variable
Page----14
3. Operator
Page----18
4. Control structure
Page----26
5. Looping
Page----39
8. String
Page----35
7. Array
Page----31
6. Looping with
pattern
Page----44
9. User defined
function
1.Introduction of c
A. History and importance of c
B. Difference between compiler and interpreter
C. Simple printf() function
D. Escape sequence character
3
A. History and importance of c
C is popular high level programming language. It was developed by Dennis Ritchie at
AT&T Bell Laboratories in 1972. It was derived from earlier programming language
called B. It was originally designed to write system programs under UNIX operating
system.
4
B. Difference between compiler and
interpreter
5
Compiler Interpreter
C, C++, Go, Fortran Python, PHP, Ruby
Language Language
Machine code Ready to run!
Ready to run! Virtual Machine
Machine code
C. Simple printf() function
6
 printf() is pre-defined function from the header stdio.h
 printf() is used to write formatted output to console
 Example -
printf(“hello!!”); output : hello!!
printf(“My age is %d”,23); output : my age is 23
where %d is format specifier for integer.
D. Escape sequence character
 It is composed of two or more character starting with backslash.
 Escape means skip.
 Sequence character means always together.
 Example -
printf(“”); output - 
printf(“n”); output - n
printf(“%%”); output - %
printf(“%%d”); output - %d
7
2. Data type, constant & variable
A. Datatype
B. Constant variable
C. Variable
8
A. Data type in c
9
Pre-defined
i.Int
ii. Float
iii. Char
iv. Void
Derived
i. Array
ii. Pointer
User-defined
i.Structure
ii. Union
iii. Enum
1 2 3
B. Constant
 Definition –
This is a variable which is only
initialized once and it’s value cannot be
modifiable.
 Note –
A constant variable name should
be in capitalized latter.
 How to create a constant variable -
1] Using a const variable.
2] By defining a marco.
3] Initialization must be done
while declaring a constant
variable.
10
 Example –
1] const float PI = 3.14;
printf(“%f”,PI);
2] #define Min 1
# define Max 9
main()
{
printf(“%d%d”,Min,Max);
}
11
C. Variable
 Definition –
It is a container which is used to store some data.
 Rules – A variable name
1] must be started with alphabet or underscore(_).
2] cannot be starts with numeric digit or any special symbol.
3] cannot contain any whitespace.
4] cannot be same as any keyword.
12
3. Operator & expression
A. Types of operator
B. Operator precedence
C. Type Conversation
13
A. Types of operator
14
Arithmetic
+
-
*
/
%
++
--
Relation
==
!=
>
<
> =
< =
Logical
&&
||
!
Bitwise
&
|
^
<<
>>
Assignment
=
+=
-=
*=
/=
%=
1 2 3 4 5 6
Miscellaneous
Size()
&
*
?:
B. Operator precedence
15
No. Priority Order
1 ( ) Left to right
2 % / * Left to right
3 + - Left to right
4 = Right to left
 Definition :
In a given expression which operator runs first and in which order.
C. Type conversation(Type casting)
16
 Definition :
Convert one data type into another data type for temporary time.
 Example :
float a;
a = 5.9;
printf(“%d”, (int)a);
4. Control structure
A. If statement
B. If else
C. Ladder
D. Nested if
E. Ternary operator
F. Switch case
17
18
18
Control structure
If
if(condition)
{
//true
}
If else Switch case
If-else If-else if Nested if
if (condition)
{
//true
}
else
{
//false
}
if(condition 1)
{
// true
}
else if(condition
2)
{
//true
}
else
{
}
if (condition 1)
{
if (condition)
{
}
else
{
}
}
else
{
if (condition)
{
}
else
{
}
}
switch (variable)
{
case 1:
break;
Case 2:
break;
default:
}
condition
?
// true
:
//false;
Ternary operate
A. If statement
19
Variable x is
less than y
Example : Find which value is less?
Output
#include<stdio.h>
Int main()
{
int x = 20;
int y = 22;
if (x<y)
{
printf(“Variable x is less than y”);
}
}
B. If else
20
The value is
greater than
10
Output
#include<stdio.h>
int main()
{ int num=19;
if (num<10)
{ printf("The value is less than 10"); }
else
{ printf("The value is greater than 10"); }
}
Example : The value is less than ten or greater than ten?
C. Ladder(steps)
21
First class
Example : Prints the grade as per the marks scored in a test.
Output
#include<stdio.h>
main()
{ int marks=83;
If(marks>75)
{ printf("First class"); }
else if(marks>65)
{ printf("Second class"); }
else if(marks>55)
{ printf("Third class"); }
else
{ printf("Fourth class"); }
}
D. Nested if
22
The value is
greater than
10
Output
Example : Checks if a number is less or greater than 10
#include<stdio.h>
main()
{ int num=100;
If(num<10)
{
if(num==1)
{ printf("The value is:%dn",num); }
else
{ printf("The value is greater than 1"); }
}
else
{ printf("The value is greater than 10"); }
}
E. Ternary operator
23
C is max
Example : find maximum number from 3 number.
Output
#include<stdio.h>
int main()
{
int a=10,b=100,c=200;
(a==b && b==c) ?
Printf(“all numbers are same”):
a>b ?
a>c ? printf(“a is max”)
: printf(“a is max”)
: b>c ? printf(“b is max”)
: printf(“c is max”);
}
F. Switch case (Menu driven)
24
The value is 8
Output
Example : Check what number is ?
#include <stdio.h>
main()
{
int num = 8;
switch (num)
{
case 7: printf("Value is 7");
break;
case 8: printf("Value is 8");
break;
case 9: printf("Value is 9");
break;
default: printf("Out of range");
}
}
5. Looping
A. While loop
B. Do while loop
C. For loop
25
26
Looping
While For
Do while
Initialization
While(condition)
{
statement
increment or
decrement
}
Initialization
do
{
Statement
increment or
decrement
}While(condition)
For
(
initial value;
condition;
increment or
decrement
)
{
statements;
}
A. While loop
27
1
2
3
4
5
6
7
8
9
10
Example : Print first 10 natural number. Output
#include <stdio.h>
void main()
{
int i=1;
while (i<=10)
{
printf("%d ",i);
i++;
}
printf("n");
}
B. Do while loop
28
1
2
3
4
5
6
7
8
9
10
Example : Print first 10 natural number.
Output
#include <stdio.h>
void main()
{
int i=1;
do
{
printf("%d ",i);
i++;
} while (i<=10);
printf("n");
}
C. For loop
29
1
2
3
4
5
6
7
8
9
10
Example : Print first 10 natural number. Output
#include <stdio.h>
void main()
{
int i;
for (i=1;i<=10;i++)
{
printf("%d ",i);
}
printf("n");
}
6. Looping with patterns
A. Without spacing
B. With spacing
C. custom
30
A. Without spacing pattern
31
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
Example : Output
#include <stdio.h>
void main()
{
int i,j;
for(i=1;i<6;i++)
{
For(j=1;j<6;j++)
{ printf(“%d ”,j); }
printf(“n”);
}
}
B. With spacing pattern
32
Example :
Output
#include <stdio.h>
void main()
{
int I , j , k;
For(i=1 ; i<=5 ; i++)
{
For(k=5;k>i ; k--)
{ printf (“ ”); }
For(j=1;j<=i ; j++)
{ printf (“%d ”,j); }
printf (“n”);
}
}
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
C. Custom
33
Example : Output
#include <stdio.h>
int main()
{ int i, j, N=5;
for(i=1; i<=N; i++)
{ for(j=1; j<=i; j++)
{ printf("%d", j); }
printf("n"); }
for(i=N-1; i>=1; i--)
{ for(j=1; j<=i; j++)
{ printf("%d", j); }
printf("n"); }
}
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
7. Array
A. 1D array
B. 2D array
34
Array
 1D array : Collection of multiple values or elements which have same data
type.
 2D array : Collection of multiple 1D array.
35
A. 1D array
36
Example : Print elements in an array
1
2
3
4
5
6
7
8
9
10
Output
#include <stdio.h>
int main()
{
int a[100];
int i, N;
printf("Enter size of array: ");
scanf("%d", &N);
printf("Enter %d elements in the array : ", N);
for(i=0; i<N; i++) { scanf("%d", &arr[i]); }
printf("nElements in array are: ");
for(i=0; i<N; i++) { printf("%d, ", arr[i]); }
}
Input
Input size: 10
Input elements:
1
2
3
4
5
6
7
8
9
10
B. 2D array
37
Example : Enter element in matrix and print.
#include<stdio.h>
void main ()
{ int arr[3][3],i,j;
Printf(“input element:n”);
for (i=0;i<3;i++)
{ for (j=0;j<3;j++)
{ scanf("%d",&arr[i][j]); } }
printf("n printing the elements ....n");
for(i=0;i<3;i++)
{ printf("n");
for (j=0;j<3;j++)
{ printf("%dt",arr[i][j]); } }
}
1 2 3
4 5 6
7 8 9
Output
Input
Input elements:
1
2
3
4
5
6
7
8
9
8. String
A. String concept
B. gets(), puts()
C. String function
38
A. String concept
The string can be defined as the one-dimensional array of characters
terminated by a null ('0'). The character array or the string is used to
manipulate text such as word or sentences.
39
B. gets() and puts()
40
gets() Puts()
 The gets() function is similar to scanf()
function but it allows entering some
characters by the user in string
 Syntax :
char[ ]
gets( char [ ])
 The puts() function is similar
to printf() function. but puts() function
is used to display only the string after
reading by gets() function entered by
user(gets similar to scanf() function)
 Syntax :
puts(char[ ])
C. String function
 strlwr() :
char a[100];
puts(“enter aby string:”);
gets(a); // WELCOME
printf(“%s”,strlwr(a)); // welcome
 strupr() :
char a[100];
puts(“enter aby string:”);
gets(a); // welcome
printf(“%s”,strupr(a)); // WELCOME
 strrev() :
char a[100];
puts(“enter aby string:”);
gets(a); // priya
printf(“%s”,strrev(a)); // ayirp
 strlen() :
char a[100];
puts(“enter aby string:”);
gets(a); // WELCOME
printf(“%s”,strlen(a)); // 7
 strcpy() :
char a[100];
strcpy(a,”home”);
puts(a); // home
9. User defined function
A. Concept of UDF
B. Recursion
42
A. Concept of UDF
43
Library function
i. printf()
ii. scanf()
iii. gets()
iv. puts()
User defined function
i. Take nothing, return nothing
ii. Take something, return nothing
iii. Take nothing, return something
iv. Take something, return something
1 2
 Definition –
A block of code that is reusable its called function.
There is two type of function :-
B. Recursion
44
24
Output
Example : Find factorial of number?
#include <stdio.h>
Int fact(int n)
{ if(n==1)
{ return 1;}
else
{ return n * fact(n-1) ;}
Void main()
{
printf(“%d ”,fact(4));
}
 Definition –
A function call it’s self that means recursion.
Thank you

More Related Content

What's hot (20)

Strings
StringsStrings
Strings
 
evolution of operating system
evolution of operating systemevolution of operating system
evolution of operating system
 
Methods in Java
Methods in JavaMethods in Java
Methods in Java
 
OOP in C++
OOP in C++OOP in C++
OOP in C++
 
C functions
C functionsC functions
C functions
 
Data types in c++
Data types in c++Data types in c++
Data types in c++
 
C Programming Unit-5
C Programming Unit-5C Programming Unit-5
C Programming Unit-5
 
Function Pointer
Function PointerFunction Pointer
Function Pointer
 
Input output statement in C
Input output statement in CInput output statement in C
Input output statement in C
 
Basics of c++ Programming Language
Basics of c++ Programming LanguageBasics of c++ Programming Language
Basics of c++ Programming Language
 
File handling in c
File handling in cFile handling in c
File handling in c
 
String in c
String in cString in c
String in c
 
Oop c++class(final).ppt
Oop c++class(final).pptOop c++class(final).ppt
Oop c++class(final).ppt
 
Input and output in C++
Input and output in C++Input and output in C++
Input and output in C++
 
C Programming Language
C Programming LanguageC Programming Language
C Programming Language
 
Functions in c
Functions in cFunctions in c
Functions in c
 
C_Programming_Notes_ICE
C_Programming_Notes_ICEC_Programming_Notes_ICE
C_Programming_Notes_ICE
 
Basics of C programming
Basics of C programmingBasics of C programming
Basics of C programming
 
Dynamic memory Allocation in c language
Dynamic memory Allocation in c languageDynamic memory Allocation in c language
Dynamic memory Allocation in c language
 
Advanced pointers
Advanced pointersAdvanced pointers
Advanced pointers
 

Similar to C language

Fundamentals of computer programming by Dr. A. Charan Kumari
Fundamentals of computer programming by Dr. A. Charan KumariFundamentals of computer programming by Dr. A. Charan Kumari
Fundamentals of computer programming by Dr. A. Charan KumariTHE NORTHCAP UNIVERSITY
 
An imperative study of c
An imperative study of cAn imperative study of c
An imperative study of cTushar B Kute
 
Fundamental of C Programming Language and Basic Input/Output Function
  Fundamental of C Programming Language and Basic Input/Output Function  Fundamental of C Programming Language and Basic Input/Output Function
Fundamental of C Programming Language and Basic Input/Output Functionimtiazalijoono
 
C programing Tutorial
C programing TutorialC programing Tutorial
C programing TutorialMahira Banu
 
Introduction to programming c and data structures
Introduction to programming c and data structuresIntroduction to programming c and data structures
Introduction to programming c and data structuresPradipta Mishra
 
Chap 2 input output dti2143
Chap 2  input output dti2143Chap 2  input output dti2143
Chap 2 input output dti2143alish sha
 
Introduction to programming c and data-structures
Introduction to programming c and data-structures Introduction to programming c and data-structures
Introduction to programming c and data-structures Pradipta Mishra
 
the refernce of programming C notes ppt.pptx
the refernce of programming C notes ppt.pptxthe refernce of programming C notes ppt.pptx
the refernce of programming C notes ppt.pptxAnkitaVerma776806
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programmingAlpana Gupta
 
Concepts of C [Module 2]
Concepts of C [Module 2]Concepts of C [Module 2]
Concepts of C [Module 2]Abhishek Sinha
 
cuptopointer-180804092048-190306091149 (2).pdf
cuptopointer-180804092048-190306091149 (2).pdfcuptopointer-180804092048-190306091149 (2).pdf
cuptopointer-180804092048-190306091149 (2).pdfYashwanthCse
 
Programming in C Presentation upto FILE
Programming in C Presentation upto FILEProgramming in C Presentation upto FILE
Programming in C Presentation upto FILEDipta Saha
 
Ch2 introduction to c
Ch2 introduction to cCh2 introduction to c
Ch2 introduction to cHattori Sidek
 

Similar to C language (20)

Fundamentals of computer programming by Dr. A. Charan Kumari
Fundamentals of computer programming by Dr. A. Charan KumariFundamentals of computer programming by Dr. A. Charan Kumari
Fundamentals of computer programming by Dr. A. Charan Kumari
 
An imperative study of c
An imperative study of cAn imperative study of c
An imperative study of c
 
Fundamental of C Programming Language and Basic Input/Output Function
  Fundamental of C Programming Language and Basic Input/Output Function  Fundamental of C Programming Language and Basic Input/Output Function
Fundamental of C Programming Language and Basic Input/Output Function
 
C programing Tutorial
C programing TutorialC programing Tutorial
C programing Tutorial
 
175035 cse lab-05
175035 cse lab-05 175035 cse lab-05
175035 cse lab-05
 
Introduction to programming c and data structures
Introduction to programming c and data structuresIntroduction to programming c and data structures
Introduction to programming c and data structures
 
Chap 2 input output dti2143
Chap 2  input output dti2143Chap 2  input output dti2143
Chap 2 input output dti2143
 
Unit-IV.pptx
Unit-IV.pptxUnit-IV.pptx
Unit-IV.pptx
 
What is c
What is cWhat is c
What is c
 
Basic of C Programming | 2022 Updated | By Shamsul H. Ansari
Basic of C Programming | 2022 Updated | By Shamsul H. AnsariBasic of C Programming | 2022 Updated | By Shamsul H. Ansari
Basic of C Programming | 2022 Updated | By Shamsul H. Ansari
 
Introduction to programming c and data-structures
Introduction to programming c and data-structures Introduction to programming c and data-structures
Introduction to programming c and data-structures
 
Unit i intro-operators
Unit   i intro-operatorsUnit   i intro-operators
Unit i intro-operators
 
Introduction to c part 2
Introduction to c   part  2Introduction to c   part  2
Introduction to c part 2
 
the refernce of programming C notes ppt.pptx
the refernce of programming C notes ppt.pptxthe refernce of programming C notes ppt.pptx
the refernce of programming C notes ppt.pptx
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programming
 
Concepts of C [Module 2]
Concepts of C [Module 2]Concepts of C [Module 2]
Concepts of C [Module 2]
 
cuptopointer-180804092048-190306091149 (2).pdf
cuptopointer-180804092048-190306091149 (2).pdfcuptopointer-180804092048-190306091149 (2).pdf
cuptopointer-180804092048-190306091149 (2).pdf
 
Programming in C Presentation upto FILE
Programming in C Presentation upto FILEProgramming in C Presentation upto FILE
Programming in C Presentation upto FILE
 
Ch2 introduction to c
Ch2 introduction to cCh2 introduction to c
Ch2 introduction to c
 
pointers 1
pointers 1pointers 1
pointers 1
 

Recently uploaded

DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerunnathinaik
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 

Recently uploaded (20)

DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developer
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 

C language

  • 2. Index 2 Page----4 1. Introduction of c Page----9 2. Datatype, constant and variable Page----14 3. Operator Page----18 4. Control structure Page----26 5. Looping Page----39 8. String Page----35 7. Array Page----31 6. Looping with pattern Page----44 9. User defined function
  • 3. 1.Introduction of c A. History and importance of c B. Difference between compiler and interpreter C. Simple printf() function D. Escape sequence character 3
  • 4. A. History and importance of c C is popular high level programming language. It was developed by Dennis Ritchie at AT&T Bell Laboratories in 1972. It was derived from earlier programming language called B. It was originally designed to write system programs under UNIX operating system. 4
  • 5. B. Difference between compiler and interpreter 5 Compiler Interpreter C, C++, Go, Fortran Python, PHP, Ruby Language Language Machine code Ready to run! Ready to run! Virtual Machine Machine code
  • 6. C. Simple printf() function 6  printf() is pre-defined function from the header stdio.h  printf() is used to write formatted output to console  Example - printf(“hello!!”); output : hello!! printf(“My age is %d”,23); output : my age is 23 where %d is format specifier for integer.
  • 7. D. Escape sequence character  It is composed of two or more character starting with backslash.  Escape means skip.  Sequence character means always together.  Example - printf(“”); output - printf(“n”); output - n printf(“%%”); output - % printf(“%%d”); output - %d 7
  • 8. 2. Data type, constant & variable A. Datatype B. Constant variable C. Variable 8
  • 9. A. Data type in c 9 Pre-defined i.Int ii. Float iii. Char iv. Void Derived i. Array ii. Pointer User-defined i.Structure ii. Union iii. Enum 1 2 3
  • 10. B. Constant  Definition – This is a variable which is only initialized once and it’s value cannot be modifiable.  Note – A constant variable name should be in capitalized latter.  How to create a constant variable - 1] Using a const variable. 2] By defining a marco. 3] Initialization must be done while declaring a constant variable. 10  Example – 1] const float PI = 3.14; printf(“%f”,PI); 2] #define Min 1 # define Max 9 main() { printf(“%d%d”,Min,Max); }
  • 11. 11
  • 12. C. Variable  Definition – It is a container which is used to store some data.  Rules – A variable name 1] must be started with alphabet or underscore(_). 2] cannot be starts with numeric digit or any special symbol. 3] cannot contain any whitespace. 4] cannot be same as any keyword. 12
  • 13. 3. Operator & expression A. Types of operator B. Operator precedence C. Type Conversation 13
  • 14. A. Types of operator 14 Arithmetic + - * / % ++ -- Relation == != > < > = < = Logical && || ! Bitwise & | ^ << >> Assignment = += -= *= /= %= 1 2 3 4 5 6 Miscellaneous Size() & * ?:
  • 15. B. Operator precedence 15 No. Priority Order 1 ( ) Left to right 2 % / * Left to right 3 + - Left to right 4 = Right to left  Definition : In a given expression which operator runs first and in which order.
  • 16. C. Type conversation(Type casting) 16  Definition : Convert one data type into another data type for temporary time.  Example : float a; a = 5.9; printf(“%d”, (int)a);
  • 17. 4. Control structure A. If statement B. If else C. Ladder D. Nested if E. Ternary operator F. Switch case 17
  • 18. 18 18 Control structure If if(condition) { //true } If else Switch case If-else If-else if Nested if if (condition) { //true } else { //false } if(condition 1) { // true } else if(condition 2) { //true } else { } if (condition 1) { if (condition) { } else { } } else { if (condition) { } else { } } switch (variable) { case 1: break; Case 2: break; default: } condition ? // true : //false; Ternary operate
  • 19. A. If statement 19 Variable x is less than y Example : Find which value is less? Output #include<stdio.h> Int main() { int x = 20; int y = 22; if (x<y) { printf(“Variable x is less than y”); } }
  • 20. B. If else 20 The value is greater than 10 Output #include<stdio.h> int main() { int num=19; if (num<10) { printf("The value is less than 10"); } else { printf("The value is greater than 10"); } } Example : The value is less than ten or greater than ten?
  • 21. C. Ladder(steps) 21 First class Example : Prints the grade as per the marks scored in a test. Output #include<stdio.h> main() { int marks=83; If(marks>75) { printf("First class"); } else if(marks>65) { printf("Second class"); } else if(marks>55) { printf("Third class"); } else { printf("Fourth class"); } }
  • 22. D. Nested if 22 The value is greater than 10 Output Example : Checks if a number is less or greater than 10 #include<stdio.h> main() { int num=100; If(num<10) { if(num==1) { printf("The value is:%dn",num); } else { printf("The value is greater than 1"); } } else { printf("The value is greater than 10"); } }
  • 23. E. Ternary operator 23 C is max Example : find maximum number from 3 number. Output #include<stdio.h> int main() { int a=10,b=100,c=200; (a==b && b==c) ? Printf(“all numbers are same”): a>b ? a>c ? printf(“a is max”) : printf(“a is max”) : b>c ? printf(“b is max”) : printf(“c is max”); }
  • 24. F. Switch case (Menu driven) 24 The value is 8 Output Example : Check what number is ? #include <stdio.h> main() { int num = 8; switch (num) { case 7: printf("Value is 7"); break; case 8: printf("Value is 8"); break; case 9: printf("Value is 9"); break; default: printf("Out of range"); } }
  • 25. 5. Looping A. While loop B. Do while loop C. For loop 25
  • 26. 26 Looping While For Do while Initialization While(condition) { statement increment or decrement } Initialization do { Statement increment or decrement }While(condition) For ( initial value; condition; increment or decrement ) { statements; }
  • 27. A. While loop 27 1 2 3 4 5 6 7 8 9 10 Example : Print first 10 natural number. Output #include <stdio.h> void main() { int i=1; while (i<=10) { printf("%d ",i); i++; } printf("n"); }
  • 28. B. Do while loop 28 1 2 3 4 5 6 7 8 9 10 Example : Print first 10 natural number. Output #include <stdio.h> void main() { int i=1; do { printf("%d ",i); i++; } while (i<=10); printf("n"); }
  • 29. C. For loop 29 1 2 3 4 5 6 7 8 9 10 Example : Print first 10 natural number. Output #include <stdio.h> void main() { int i; for (i=1;i<=10;i++) { printf("%d ",i); } printf("n"); }
  • 30. 6. Looping with patterns A. Without spacing B. With spacing C. custom 30
  • 31. A. Without spacing pattern 31 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 Example : Output #include <stdio.h> void main() { int i,j; for(i=1;i<6;i++) { For(j=1;j<6;j++) { printf(“%d ”,j); } printf(“n”); } }
  • 32. B. With spacing pattern 32 Example : Output #include <stdio.h> void main() { int I , j , k; For(i=1 ; i<=5 ; i++) { For(k=5;k>i ; k--) { printf (“ ”); } For(j=1;j<=i ; j++) { printf (“%d ”,j); } printf (“n”); } } 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5
  • 33. C. Custom 33 Example : Output #include <stdio.h> int main() { int i, j, N=5; for(i=1; i<=N; i++) { for(j=1; j<=i; j++) { printf("%d", j); } printf("n"); } for(i=N-1; i>=1; i--) { for(j=1; j<=i; j++) { printf("%d", j); } printf("n"); } } 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5 1 2 3 4 1 2 3 1 2 1
  • 34. 7. Array A. 1D array B. 2D array 34
  • 35. Array  1D array : Collection of multiple values or elements which have same data type.  2D array : Collection of multiple 1D array. 35
  • 36. A. 1D array 36 Example : Print elements in an array 1 2 3 4 5 6 7 8 9 10 Output #include <stdio.h> int main() { int a[100]; int i, N; printf("Enter size of array: "); scanf("%d", &N); printf("Enter %d elements in the array : ", N); for(i=0; i<N; i++) { scanf("%d", &arr[i]); } printf("nElements in array are: "); for(i=0; i<N; i++) { printf("%d, ", arr[i]); } } Input Input size: 10 Input elements: 1 2 3 4 5 6 7 8 9 10
  • 37. B. 2D array 37 Example : Enter element in matrix and print. #include<stdio.h> void main () { int arr[3][3],i,j; Printf(“input element:n”); for (i=0;i<3;i++) { for (j=0;j<3;j++) { scanf("%d",&arr[i][j]); } } printf("n printing the elements ....n"); for(i=0;i<3;i++) { printf("n"); for (j=0;j<3;j++) { printf("%dt",arr[i][j]); } } } 1 2 3 4 5 6 7 8 9 Output Input Input elements: 1 2 3 4 5 6 7 8 9
  • 38. 8. String A. String concept B. gets(), puts() C. String function 38
  • 39. A. String concept The string can be defined as the one-dimensional array of characters terminated by a null ('0'). The character array or the string is used to manipulate text such as word or sentences. 39
  • 40. B. gets() and puts() 40 gets() Puts()  The gets() function is similar to scanf() function but it allows entering some characters by the user in string  Syntax : char[ ] gets( char [ ])  The puts() function is similar to printf() function. but puts() function is used to display only the string after reading by gets() function entered by user(gets similar to scanf() function)  Syntax : puts(char[ ])
  • 41. C. String function  strlwr() : char a[100]; puts(“enter aby string:”); gets(a); // WELCOME printf(“%s”,strlwr(a)); // welcome  strupr() : char a[100]; puts(“enter aby string:”); gets(a); // welcome printf(“%s”,strupr(a)); // WELCOME  strrev() : char a[100]; puts(“enter aby string:”); gets(a); // priya printf(“%s”,strrev(a)); // ayirp  strlen() : char a[100]; puts(“enter aby string:”); gets(a); // WELCOME printf(“%s”,strlen(a)); // 7  strcpy() : char a[100]; strcpy(a,”home”); puts(a); // home
  • 42. 9. User defined function A. Concept of UDF B. Recursion 42
  • 43. A. Concept of UDF 43 Library function i. printf() ii. scanf() iii. gets() iv. puts() User defined function i. Take nothing, return nothing ii. Take something, return nothing iii. Take nothing, return something iv. Take something, return something 1 2  Definition – A block of code that is reusable its called function. There is two type of function :-
  • 44. B. Recursion 44 24 Output Example : Find factorial of number? #include <stdio.h> Int fact(int n) { if(n==1) { return 1;} else { return n * fact(n-1) ;} Void main() { printf(“%d ”,fact(4)); }  Definition – A function call it’s self that means recursion.