C++ Numbers

defining numbers in c++

code:

#include<iostreaM>
using namespace std;

int main()
{

    //declaring the numbers
short s;
int i;
long l;
float f;
double d;

//defining the values

s=10;
i=1000;
l=1000000;
f=230.47;
d=30949.374;

//printing the numbers

cout<<"short s"<<s<<endl;
cout<<"int i"<<i<<endl;
cout<<"long l"<<l<<endl;
cout<<"float f"<<f<<endl;
cout<<"double d"<<d<<endl;



    return 0;
}

Mathematical Functions:

C++ has some predefined library functions for mathematical calculation.We have to use the header #include<cmath> for using this

example:

#include<iostream>
#include<cmath>
using namespace std;

int main(){

short s=10;
int i=-1000;
long l=100000;
float f=230.47;
double d=200.374;

//mathematical operations

cout<<"sin(d)"<<sin(d)<<endl;
cout<<"abs(i)"<<abs(i)<<endl;
cout<<"floor(d)"<<floor(d)<<endl;
cout<<"sqrt(f)"<<sqrt(f)<<endl;
cout<<"pow(d,2)"<<pow(d,2)<<endl;
return 0;
}

 

 

It would be a great help, if you support by sharing :)
Author: zakilive

Leave a Reply

Your email address will not be published.