MS Rumi. Powered by Blogger.

Friday 25 April 2014

Power Of X In C++

By Unknown  |  03:03 No comments

File Handling Example In C++

Write a C++ Program that computes the equation (y) to the power of (x) and print the result on file.

//Before creating this program. Create a txt file on note pad with "powerX.txt" name.

#include<iostream.h>
#include<fstream.h>
void main ()
{
int number,power,result=1;

ofstream powers;
powers.open("powerX.txt");
cout<<"Enter Numbers:";
cin>>number;
cout<<"Enter Power:";
cin>>power;
for(int i=1; i<=power; i++)
{
result=number*result;
}



powers<<"Number:"<<number<<"\nPower:"<<power<<endl;
powers<<"Result:"<<result;


}

OUT PUT On FILE

Author: Unknown

Hello, I am Author, thanks for visiting my blog. Bookmark this....

0 comments:

E-mail Newsletter

Sign up now to receive breaking news and to hear what's new with us.

Recent Articles

TOP