0% found this document useful (0 votes)
27 views

Buildin Function Sample Program

This C++ program contains code to calculate the square root of two numbers, raise one number to the power of another, and demonstrate various increment/decrement and assignment operators. It takes in two numbers, calculates their square roots, and raises the first number to the power of the second. It then shows the effects of postfix increment, postfix decrement, addition assignment, subtraction assignment, multiplication assignment on some sample integer variables.

Uploaded by

Ali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views

Buildin Function Sample Program

This C++ program contains code to calculate the square root of two numbers, raise one number to the power of another, and demonstrate various increment/decrement and assignment operators. It takes in two numbers, calculates their square roots, and raises the first number to the power of the second. It then shows the effects of postfix increment, postfix decrement, addition assignment, subtraction assignment, multiplication assignment on some sample integer variables.

Uploaded by

Ali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

#include <iostream>

#include <cstdlib>
#include<cmath>
using namespace std;
int main ()
{
//Square Root and power of a number
cout<<"Square Root and power of a number"<<endl;
double a,b;
double sqrtA, sqrtB, powerNum;
cout<<"Enter a and b: \n";
cin>>a>>b;
sqrtA = sqrt(a);
sqrtB = sqrt(b);
cout<<fixed;
cout.precision (2);
cout<<"the square root of "<<a <<" is "<<sqrtA<<endl;
cout<<"the square root of "<<b <<" is "<<sqrtB<<endl;
powerNum = pow (a,b);
cout <<a<<" to the power of "<<b<<" is "<<powerNum<<endl;

//increment and decrement examples


cout<<" "<<endl;
cout<<"Increment and Decrement examples"<<endl;
int m=66;
cout<<"m="<<m<<endl;
m++;
cout<<"m++"<< " is "<<m<<endl;
int n=25;
cout<<"n="<<n<<endl;
n--;
cout<<"n--"<< " is "<<n<<endl;
int p=89;
cout<<"p="<<p<<endl;
p+=5;
cout<<"p+=5"<< " is "<<p<<endl;
int x=74;
cout<<"x="<<x<<endl;
x-=3;
cout<<"x-=3"<<" is "<<x<<endl;
int y=10;
cout<<"y="<<y<<endl;
y*=2;
cout<<"y*=2"<<" is "<<y<<endl;
system ("pause");
return 0;
}

You might also like