0% found this document useful (0 votes)
167 views25 pages

Cmath

This document discusses iostream and cmath header files in C++. It provides examples of using built-in functions like cout, cin, sqrt, pow, sin, cos, and tan. Cout is used for output and cin for input. Cmath contains common math functions that must be included. Examples demonstrate declaring and initializing variables, taking user input, performing calculations, and outputting results.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
167 views25 pages

Cmath

This document discusses iostream and cmath header files in C++. It provides examples of using built-in functions like cout, cin, sqrt, pow, sin, cos, and tan. Cout is used for output and cin for input. Cmath contains common math functions that must be included. Examples demonstrate declaring and initializing variables, taking user input, performing calculations, and outputting results.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 25

Presentation By

MUHAMMAD AHMAD BAJWA


FA16-BCS-057
M. AHMAD RANA
FA16-BCS-058
TALHA MIRZA
FA16-BCS-089
MUHAMMAD JAMSHAID IQBAL
FA16-BCS-106

What is iostream
Iostream is a header file that is part of the C++

standard library (the name stands for Input/Output


Stream).

Working of iostream
Iostream controls the flow if input and output of the

program.

Built-in Functions of iostream


There are two types of built-in functions in iostream.

Cin
Cout

Cout

Cout stands for console output.


It is used to get the output of a C++ program.
<< is used with the cout.

Syntax
Its syntax is:

Cout<<String constant;
With one variable its syntax is :
Cout<<String constant <<variable_name;
With Multiple variable can also be used with cout
Cout<<String Constant <<v1<<v2<<v3;

cin
Cin stands for console input.
It is used to get the input from the user in a C++

program.
Insertion operator >> is used with it.

Syntax
Its syntax is :

With Single Variable:


Cin>>v1;
With multiple Variables :
Cin>>v1>>v2>>v3;

Example
#include<iostream>
Using namespace std;
Void main()
{
Cout<<My name is XYZ ;
Cout<<My name is XYZ;
Cout<<My name is XYZ;
System(pause);
}

Example
Cin with single variable
#include<iostream>
using namespace std;
void main()
{
int i;
cout<<"Enter the Value of i ";
cin>>i;
system("pause");
}

Example
#include<iostream>
using namespace std;
void main()
{
int I,j,k;
cout<<"Enter the Value of i ";
cin>>i;
cout<<"Enter the Value of j ";
cin>>j;
cout<<"Enter the Value of k ";
cin>>k;
system("pause");
}

Example

#include<iostream>
using namespace std;
void main()
{
int I,j,k;
cout<<"Enter the Value of I & j ";
cin>>i>>j;
Cout<<Value of
system("pause");
}

Example
#include<iostream>
using namespace std;
void main()
{
int i;
cout<<"Enter the Value of i ";
cin>>i;
cout<<"Value of i is "<<i;
system("pause");
}

Example
#include<iostream>
using namespace std;
void main()
{
int i;
cout<<"Enter the Value of i ";
cin>>i;
cout<<"Value of i is "<<i;
system("pause");
}

Example

#include<iostream>
using namespace std;
void main()
{
int i,j;
cout<<"Enter the Value of I & j ";
cin>>i>>j;
cout<<"Value of i and j is "<<i<<"\t"<<j;
system("pause");
}

cmath
cmath is a header file that is part of the C++

standard library.
It is included in a C++ program to use the multiple
math functions .
It is included at the top of a C++ program.

Built-in functios
There are multiple built-in functions in cmath.
Some of the functions are:

Example
# include < iostream >
# include < cm ath>
using nam espace std;
int m ain ()
{
double x;
cout< < "Enter a num ber to get it's sin ";
cin> > x;
double a = sin(x * (3.1415 / 180));
cout < < "sin of entered value is "< < a;
system ("pause");
return 0;
}

Example
# include < iostream >
# include < cm ath>
using nam espace std;
int m ain ()
{double i= 12;
double x= sqrt(i);
cout< < x;
system ("pause");
return 0;
}

Example
# include < iostream >
# include < cm ath>
using nam espace std;
int m ain()
{
double t= 14;
double e= 2;
double ee= pow (t, e);
cout< < ee;
system ("pause");
return 0;
}

Example
# include < iostream >
# include < cm ath>
using nam espace std;
int m ain ()
{
double x;
cout< < "Enter a num ber to get it's sin ";
cin> > x;
double a = cos(x * (3.1415 / 180));
cout < < cos of entered value is "< < a;
system ("pause");
return 0;
}

Example
# include < iostream >
# include < cm ath>
using nam espace std;
int m ain ()
{
double x;
cout< < "Enter a num ber to get it's sin ";
cin> > x;
double a = tan(x * (3.1415 / 180));
cout < < "tan of entered value is "< < a;
system ("pause");
return 0;
}

Example
# include < iostream >
# include < cm ath>
using nam espace std;
int m ain ()
{
double x;
cout< < "Enter a num ber to get it's sin ";
cin> > x;
double a = sinh(x * (3.1415 / 180));
cout < < hyperbolic sin of entered value is "< < a;
system ("pause");
return 0;
}

The End

You might also like