#include<iostream>
#include<iomanip>
using namespace std;
void DrawBox(int rows, int cols, char symbol)
{
int r, c;
for(r=1; r<= rows; r++)
{
for(c=1; c<=cols; c++)
cout<<symbol;
cout<<endl;
}
}
double Power(int num, double pow)
{
int i;
double answer=1;
for(i =0; i<pow; i++)
answer*=num;
return answer;
}
void main()
{
int rows;
int cols;
int num;
double pow;
char symbol;
cout<<"How many rows would you like? ";
cin>>rows;
cout<<"How many columns would you like? ";
cin>> cols;
cout<< "What type of symbol do you want? ";
cin>> symbol;
DrawBox(rows, cols, symbol);
cout<<endl;
cout<<"Give a number: ";
cin>> num;
cout<<"What power would you want to raise that number: ";
cin>>pow;
pow =Power(num, pow);
cout<<fixed<<pow<<endl;
}
Help with formatting numbersi need help trying to figure out how to get rid of zeros at the end of
Page 1 of 1
2 Replies - 412 Views - Last Post: 08 October 2008 - 01:22 PM
#1
Help with formatting numbers
Posted 08 October 2008 - 10:41 AM
Here is my code, I want to know if i can get rid of all zeros at the end of my output.
Replies To: Help with formatting numbers
#2
Re: Help with formatting numbers
Posted 08 October 2008 - 11:48 AM
what is the output there.
#3
Re: Help with formatting numbers
Posted 08 October 2008 - 01:22 PM
Have you tried using setprecision(x) yet? X meaning the number of decimal places you would like to display. So your code would look like:
if you wanted no 0's to display.
cout<<fixed<<setprecision(0)<<pow<<endl;
if you wanted no 0's to display.
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote




|