SlideShare une entreprise Scribd logo
1  sur  13
1. Converting by assignment
operator
2. Using cast operator
Syntax:
(cast_type) expression;
or
cast_type (expression);
09/04/131 VIT - SCSE
Type Conversion
#include<iostream.h>
#include<conio.h>
void main()
{
char ch='A';
int x;
x=(int)ch;
cout<<x;
getch();
}
Enum Types
The enum keyword automatically enumerates a list of words
by assigning them values 0,1,2,3,4, and so on.
The general form of enum is:
enum variable_name{ list of constants separated by commas };
e.g:
enum day{sun,mon,tue,wed,thu,fri,sat};
09/04/132 VIT - SCSE
# include<iostream.h>
enum day{sun,mon,tue,wed,thu,fri,sat};
void main( )
{
day d1, d2,d3;
d1 = mon;
d2 = fri;
int diff = d2 – d1;
cout<<"days between = "<<diff<<endl;
if(d1<d2)
cout<< "day1 comes before day2n";
}
09/04/133 VIT - SCSE
Functions
A function groups a number of program statements into a
unit and gives it a name.
This unit can then be invoked from other parts of the
program.
It is used to reduce program size.
The main advantages of using a function are:
1. Easy to write a correct small function
2. Easy to read, write and debug a function
3. Easier to maintain or modify such a function
4. It can be called any number of times in any place with
different parameters
09/04/134 VIT - SCSE
09/04/135 VIT - SCSE
The Function Declaration
The Function Definition
Function Calling
Return statement
The keyword return is used to terminate function and return
a value to its caller.
The return statement may also be used to exit a function
without returning a value.
The general form of the return statement is.
 return;
 return ( expression);
09/04/136 VIT - SCSE
//using multiple return
statements in a function
# include<iostream.h>
void main()
{
float maximum( float, float, float);
float x,y,z,max;
cout<<"Enter three numbers";
cin>>x>>y>>z;
max = maximum(x,y,z);
cout<<"maximum"<<max;
}
float maximum(float a,float b,float c)
{
09/04/137 VIT - SCSE
if(a>b)
{
if(a>c)
return (a);
else
return (c);
}
else
{
if(b>c)
return (b);
else
return (c);
}
}
Types of functions
A function is invoked without passing any formal
argument does not return any value to the calling
portion.
A function is invoked with formal argument and
does not return any value to the calling portion.
A function is invoked with formal argument and
returns back a value to the calling environment.
09/04/138 VIT - SCSE
Function Arguments
The arguments can be classified into two groups:
1. Actual argument
2. Formal argument
Local and Global variable
09/04/139 VIT - SCSE
A function which calls itself directly or indirectly again and again is
known as the recursive function.
09/04/1310 VIT - SCSE
Recursive function
int sum(int n)
{
int value=0;
if(n= = 0)
return(value);
else
value = n+sum(n-1);
return(value);
}
# include<iostream.h>
void main()
{
int sum(int);
int n,temp;
cout<<"Enter any integer
number"<<endl;
cin>>n;
temp = sum(n);
cout<<"value = "<<n<<"and its
sum ="<< temp;
}
E.x: void sum(int a,int b,int c=6,int d=10);
09/04/1311 VIT - SCSE
Default arguments
void sum(int a1,int
a2,int a3,int a4)
{
int temp;
temp = a1+a2+a3+a4;
cout<<"sum="<<temp;
}
// default argument declaration
# include<iostream.h>
void sum(int a,int b,int c=6,int d=10);
//default argument
initialization
void main()
{
int a,b,c,d;
cout<<"enter any two
numbers"<<endl;
cin>>a>>b;
sum(a,b); //sum of default values
}
09/04/1312 VIT - SCSE
Function Overloading
cout<<add(5,10);
cout<<add(15,10.0);
cout<<add(12.5,7.5);
cout<<add(5.10,15);
cout<<add(0.75,5);
int add(int a,int b);
int add(int a,int b,int c);
double add(double x,double y);
double add(int p,double q);
double add(double p,int q);
09/04/1313 VIT - SCSE
Function Overloading
double volume(double r,int h)
{
return(3.14519*r*r*h);
}
long volume(long l,int b,int h)
{
return (1*b*h);
}
#include<iostream.h>
int volume(int);
double volume(double,int);
long volume(long,int,int);
main()
{
cout<<volume(10)<< endl;
cout<<volume(2.5,8)<<endl;
cout<<volume(100L,75,15);
getch();
return 0;
}
int volume(int s)
{
return (s*s*s);
}

Contenu connexe

Tendances

Formatted Console I/O Operations in C++
Formatted Console I/O Operations in C++Formatted Console I/O Operations in C++
Formatted Console I/O Operations in C++sujathavvv
 
When RV Meets CEP (RV 2016 Tutorial)
When RV Meets CEP (RV 2016 Tutorial)When RV Meets CEP (RV 2016 Tutorial)
When RV Meets CEP (RV 2016 Tutorial)Sylvain Hallé
 
9 character string &amp; string library
9  character string &amp; string library9  character string &amp; string library
9 character string &amp; string libraryMomenMostafa
 
Activity Recognition Through Complex Event Processing: First Findings
Activity Recognition Through Complex Event Processing: First Findings Activity Recognition Through Complex Event Processing: First Findings
Activity Recognition Through Complex Event Processing: First Findings Sylvain Hallé
 
Shell programming 2
Shell programming 2Shell programming 2
Shell programming 2Gourav Varma
 
Shell programming 2
Shell programming 2Shell programming 2
Shell programming 2Kalkey
 
Data Structure - 2nd Study
Data Structure - 2nd StudyData Structure - 2nd Study
Data Structure - 2nd StudyChris Ohk
 
C++totural file
C++totural fileC++totural file
C++totural filehalaisumit
 
array, function, pointer, pattern matching
array, function, pointer, pattern matchingarray, function, pointer, pattern matching
array, function, pointer, pattern matchingShakila Mahjabin
 
Aae oop xp_06
Aae oop xp_06Aae oop xp_06
Aae oop xp_06Niit Care
 
built in function
built in functionbuilt in function
built in functionkinzasaeed4
 
C programming - String
C programming - StringC programming - String
C programming - StringAchyut Devkota
 
6 c control statements branching &amp; jumping
6 c control statements branching &amp; jumping6 c control statements branching &amp; jumping
6 c control statements branching &amp; jumpingMomenMostafa
 
Dynamic Objects,Pointer to function,Array & Pointer,Character String Processing
Dynamic Objects,Pointer to function,Array & Pointer,Character String ProcessingDynamic Objects,Pointer to function,Array & Pointer,Character String Processing
Dynamic Objects,Pointer to function,Array & Pointer,Character String ProcessingMeghaj Mallick
 

Tendances (20)

7 functions
7  functions7  functions
7 functions
 
14 strings
14 strings14 strings
14 strings
 
Formatted Console I/O Operations in C++
Formatted Console I/O Operations in C++Formatted Console I/O Operations in C++
Formatted Console I/O Operations in C++
 
When RV Meets CEP (RV 2016 Tutorial)
When RV Meets CEP (RV 2016 Tutorial)When RV Meets CEP (RV 2016 Tutorial)
When RV Meets CEP (RV 2016 Tutorial)
 
String in c
String in cString in c
String in c
 
Strings
StringsStrings
Strings
 
9 character string &amp; string library
9  character string &amp; string library9  character string &amp; string library
9 character string &amp; string library
 
Activity Recognition Through Complex Event Processing: First Findings
Activity Recognition Through Complex Event Processing: First Findings Activity Recognition Through Complex Event Processing: First Findings
Activity Recognition Through Complex Event Processing: First Findings
 
Shell programming 2
Shell programming 2Shell programming 2
Shell programming 2
 
Shell programming 2
Shell programming 2Shell programming 2
Shell programming 2
 
Data Structure - 2nd Study
Data Structure - 2nd StudyData Structure - 2nd Study
Data Structure - 2nd Study
 
C++totural file
C++totural fileC++totural file
C++totural file
 
array, function, pointer, pattern matching
array, function, pointer, pattern matchingarray, function, pointer, pattern matching
array, function, pointer, pattern matching
 
Aae oop xp_06
Aae oop xp_06Aae oop xp_06
Aae oop xp_06
 
built in function
built in functionbuilt in function
built in function
 
C programming - String
C programming - StringC programming - String
C programming - String
 
Lecture 2. mte 407
Lecture 2. mte 407Lecture 2. mte 407
Lecture 2. mte 407
 
C++ tutorial
C++ tutorialC++ tutorial
C++ tutorial
 
6 c control statements branching &amp; jumping
6 c control statements branching &amp; jumping6 c control statements branching &amp; jumping
6 c control statements branching &amp; jumping
 
Dynamic Objects,Pointer to function,Array & Pointer,Character String Processing
Dynamic Objects,Pointer to function,Array & Pointer,Character String ProcessingDynamic Objects,Pointer to function,Array & Pointer,Character String Processing
Dynamic Objects,Pointer to function,Array & Pointer,Character String Processing
 

En vedette

3 1. preprocessor, math, stdlib
3 1. preprocessor, math, stdlib3 1. preprocessor, math, stdlib
3 1. preprocessor, math, stdlib웅식 전
 
Do...while loop structure
Do...while loop structureDo...while loop structure
Do...while loop structureJd Mercado
 
Lecture13 control statementswitch.ppt
Lecture13 control statementswitch.pptLecture13 control statementswitch.ppt
Lecture13 control statementswitch.ppteShikshak
 
Type conversions
Type conversionsType conversions
Type conversionssanya6900
 
Data Type Conversion in C++
Data Type Conversion in C++Data Type Conversion in C++
Data Type Conversion in C++Danial Mirza
 
c++ programming Unit 2 basic structure of a c++ program
c++ programming Unit 2 basic structure of a c++ programc++ programming Unit 2 basic structure of a c++ program
c++ programming Unit 2 basic structure of a c++ programAAKASH KUMAR
 
Do While and While Loop
Do While and While LoopDo While and While Loop
Do While and While LoopHock Leng PUAH
 
Looping statements in Java
Looping statements in JavaLooping statements in Java
Looping statements in JavaJin Castor
 
Basic structure of C++ program
Basic structure of C++ programBasic structure of C++ program
Basic structure of C++ programmatiur rahman
 

En vedette (12)

3 1. preprocessor, math, stdlib
3 1. preprocessor, math, stdlib3 1. preprocessor, math, stdlib
3 1. preprocessor, math, stdlib
 
Do...while loop structure
Do...while loop structureDo...while loop structure
Do...while loop structure
 
Lecture13 control statementswitch.ppt
Lecture13 control statementswitch.pptLecture13 control statementswitch.ppt
Lecture13 control statementswitch.ppt
 
Type conversions
Type conversionsType conversions
Type conversions
 
Type Casting in C++
Type Casting in C++Type Casting in C++
Type Casting in C++
 
Data Type Conversion in C++
Data Type Conversion in C++Data Type Conversion in C++
Data Type Conversion in C++
 
c++ programming Unit 2 basic structure of a c++ program
c++ programming Unit 2 basic structure of a c++ programc++ programming Unit 2 basic structure of a c++ program
c++ programming Unit 2 basic structure of a c++ program
 
Do While and While Loop
Do While and While LoopDo While and While Loop
Do While and While Loop
 
Looping statements in Java
Looping statements in JavaLooping statements in Java
Looping statements in Java
 
Basic structure of C++ program
Basic structure of C++ programBasic structure of C++ program
Basic structure of C++ program
 
Hard disk
Hard diskHard disk
Hard disk
 
Hard disk PPT
Hard disk PPTHard disk PPT
Hard disk PPT
 

Similaire à 4 Type conversion functions

2 BytesC++ course_2014_c3_ function basics&parameters and overloading
2 BytesC++ course_2014_c3_ function basics&parameters and overloading2 BytesC++ course_2014_c3_ function basics&parameters and overloading
2 BytesC++ course_2014_c3_ function basics&parameters and overloadingkinan keshkeh
 
UNIT3.pptx
UNIT3.pptxUNIT3.pptx
UNIT3.pptxNagasaiT
 
Add a function prototype for the function sumNum- # include using nam.docx
Add a function prototype for the function sumNum- # include  using nam.docxAdd a function prototype for the function sumNum- # include  using nam.docx
Add a function prototype for the function sumNum- # include using nam.docxwviola
 
how to reuse code
how to reuse codehow to reuse code
how to reuse codejleed1
 
Part 3-functions1-120315220356-phpapp01
Part 3-functions1-120315220356-phpapp01Part 3-functions1-120315220356-phpapp01
Part 3-functions1-120315220356-phpapp01Abdul Samee
 
Object oriented programming system with C++
Object oriented programming system with C++Object oriented programming system with C++
Object oriented programming system with C++msharshitha03s
 
Introduction to Basic C programming 01
Introduction to Basic C programming 01Introduction to Basic C programming 01
Introduction to Basic C programming 01Wingston
 
Classes function overloading
Classes function overloadingClasses function overloading
Classes function overloadingankush_kumar
 
To write a program that implements the following C++ concepts 1. Dat.pdf
To write a program that implements the following C++ concepts 1. Dat.pdfTo write a program that implements the following C++ concepts 1. Dat.pdf
To write a program that implements the following C++ concepts 1. Dat.pdfSANDEEPARIHANT
 

Similaire à 4 Type conversion functions (20)

2 BytesC++ course_2014_c3_ function basics&parameters and overloading
2 BytesC++ course_2014_c3_ function basics&parameters and overloading2 BytesC++ course_2014_c3_ function basics&parameters and overloading
2 BytesC++ course_2014_c3_ function basics&parameters and overloading
 
6 pointers functions
6 pointers functions6 pointers functions
6 pointers functions
 
UNIT3.pptx
UNIT3.pptxUNIT3.pptx
UNIT3.pptx
 
CP 04.pptx
CP 04.pptxCP 04.pptx
CP 04.pptx
 
Add a function prototype for the function sumNum- # include using nam.docx
Add a function prototype for the function sumNum- # include  using nam.docxAdd a function prototype for the function sumNum- # include  using nam.docx
Add a function prototype for the function sumNum- # include using nam.docx
 
11 functions
11 functions11 functions
11 functions
 
C++ Language
C++ LanguageC++ Language
C++ Language
 
C++ file
C++ fileC++ file
C++ file
 
C++ file
C++ fileC++ file
C++ file
 
how to reuse code
how to reuse codehow to reuse code
how to reuse code
 
Function in C program
Function in C programFunction in C program
Function in C program
 
Part 3-functions1-120315220356-phpapp01
Part 3-functions1-120315220356-phpapp01Part 3-functions1-120315220356-phpapp01
Part 3-functions1-120315220356-phpapp01
 
3. control statement
3. control statement3. control statement
3. control statement
 
3. chapter ii
3. chapter ii3. chapter ii
3. chapter ii
 
C++ TUTORIAL 8
C++ TUTORIAL 8C++ TUTORIAL 8
C++ TUTORIAL 8
 
Object oriented programming system with C++
Object oriented programming system with C++Object oriented programming system with C++
Object oriented programming system with C++
 
Functions in c
Functions in cFunctions in c
Functions in c
 
Introduction to Basic C programming 01
Introduction to Basic C programming 01Introduction to Basic C programming 01
Introduction to Basic C programming 01
 
Classes function overloading
Classes function overloadingClasses function overloading
Classes function overloading
 
To write a program that implements the following C++ concepts 1. Dat.pdf
To write a program that implements the following C++ concepts 1. Dat.pdfTo write a program that implements the following C++ concepts 1. Dat.pdf
To write a program that implements the following C++ concepts 1. Dat.pdf
 

Plus de Docent Education

Plus de Docent Education (14)

17 files and streams
17 files and streams17 files and streams
17 files and streams
 
16 virtual function
16 virtual function16 virtual function
16 virtual function
 
14 operator overloading
14 operator overloading14 operator overloading
14 operator overloading
 
13 exception handling
13 exception handling13 exception handling
13 exception handling
 
12 constructors invocation and data members initialization
12 constructors invocation and data members initialization12 constructors invocation and data members initialization
12 constructors invocation and data members initialization
 
12 constructors invocation and data members initialization
12 constructors invocation and data members initialization12 constructors invocation and data members initialization
12 constructors invocation and data members initialization
 
11 constructors in derived classes
11 constructors in derived classes11 constructors in derived classes
11 constructors in derived classes
 
10 inheritance
10 inheritance10 inheritance
10 inheritance
 
7 class objects
7 class objects7 class objects
7 class objects
 
5 array
5 array5 array
5 array
 
1 Intro Object Oriented Programming
1  Intro Object Oriented Programming1  Intro Object Oriented Programming
1 Intro Object Oriented Programming
 
3 intro basic_elements
3 intro basic_elements3 intro basic_elements
3 intro basic_elements
 
2 Intro c++
2 Intro c++2 Intro c++
2 Intro c++
 
unit-1-intro
 unit-1-intro unit-1-intro
unit-1-intro
 

Dernier

Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...AliaaTarek5
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditSkynet Technologies
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 

Dernier (20)

Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance Audit
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 

4 Type conversion functions

  • 1. 1. Converting by assignment operator 2. Using cast operator Syntax: (cast_type) expression; or cast_type (expression); 09/04/131 VIT - SCSE Type Conversion #include<iostream.h> #include<conio.h> void main() { char ch='A'; int x; x=(int)ch; cout<<x; getch(); }
  • 2. Enum Types The enum keyword automatically enumerates a list of words by assigning them values 0,1,2,3,4, and so on. The general form of enum is: enum variable_name{ list of constants separated by commas }; e.g: enum day{sun,mon,tue,wed,thu,fri,sat}; 09/04/132 VIT - SCSE
  • 3. # include<iostream.h> enum day{sun,mon,tue,wed,thu,fri,sat}; void main( ) { day d1, d2,d3; d1 = mon; d2 = fri; int diff = d2 – d1; cout<<"days between = "<<diff<<endl; if(d1<d2) cout<< "day1 comes before day2n"; } 09/04/133 VIT - SCSE
  • 4. Functions A function groups a number of program statements into a unit and gives it a name. This unit can then be invoked from other parts of the program. It is used to reduce program size. The main advantages of using a function are: 1. Easy to write a correct small function 2. Easy to read, write and debug a function 3. Easier to maintain or modify such a function 4. It can be called any number of times in any place with different parameters 09/04/134 VIT - SCSE
  • 5. 09/04/135 VIT - SCSE The Function Declaration The Function Definition Function Calling
  • 6. Return statement The keyword return is used to terminate function and return a value to its caller. The return statement may also be used to exit a function without returning a value. The general form of the return statement is.  return;  return ( expression); 09/04/136 VIT - SCSE
  • 7. //using multiple return statements in a function # include<iostream.h> void main() { float maximum( float, float, float); float x,y,z,max; cout<<"Enter three numbers"; cin>>x>>y>>z; max = maximum(x,y,z); cout<<"maximum"<<max; } float maximum(float a,float b,float c) { 09/04/137 VIT - SCSE if(a>b) { if(a>c) return (a); else return (c); } else { if(b>c) return (b); else return (c); } }
  • 8. Types of functions A function is invoked without passing any formal argument does not return any value to the calling portion. A function is invoked with formal argument and does not return any value to the calling portion. A function is invoked with formal argument and returns back a value to the calling environment. 09/04/138 VIT - SCSE
  • 9. Function Arguments The arguments can be classified into two groups: 1. Actual argument 2. Formal argument Local and Global variable 09/04/139 VIT - SCSE
  • 10. A function which calls itself directly or indirectly again and again is known as the recursive function. 09/04/1310 VIT - SCSE Recursive function int sum(int n) { int value=0; if(n= = 0) return(value); else value = n+sum(n-1); return(value); } # include<iostream.h> void main() { int sum(int); int n,temp; cout<<"Enter any integer number"<<endl; cin>>n; temp = sum(n); cout<<"value = "<<n<<"and its sum ="<< temp; }
  • 11. E.x: void sum(int a,int b,int c=6,int d=10); 09/04/1311 VIT - SCSE Default arguments void sum(int a1,int a2,int a3,int a4) { int temp; temp = a1+a2+a3+a4; cout<<"sum="<<temp; } // default argument declaration # include<iostream.h> void sum(int a,int b,int c=6,int d=10); //default argument initialization void main() { int a,b,c,d; cout<<"enter any two numbers"<<endl; cin>>a>>b; sum(a,b); //sum of default values }
  • 12. 09/04/1312 VIT - SCSE Function Overloading cout<<add(5,10); cout<<add(15,10.0); cout<<add(12.5,7.5); cout<<add(5.10,15); cout<<add(0.75,5); int add(int a,int b); int add(int a,int b,int c); double add(double x,double y); double add(int p,double q); double add(double p,int q);
  • 13. 09/04/1313 VIT - SCSE Function Overloading double volume(double r,int h) { return(3.14519*r*r*h); } long volume(long l,int b,int h) { return (1*b*h); } #include<iostream.h> int volume(int); double volume(double,int); long volume(long,int,int); main() { cout<<volume(10)<< endl; cout<<volume(2.5,8)<<endl; cout<<volume(100L,75,15); getch(); return 0; } int volume(int s) { return (s*s*s); }