
Patrick B. answered 11/11/20
Math and computer tutor/teacher
using namespace std;
//THESE HEADERS ARE REQUIRED !!!!
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
vertical_print_str( char * str)
{
int N = strlen(str);
for (int iLoop=0; iLoop<N; iLoop++)
{
cout << str[iLoop] << endl;
}
}
vertical_print_int( long longIntNum)
{
char printBuff[1024];
memset(printBuff,0,1024); //null terminates the buffer
//writes the integer to the buffer
sprintf(printBuff,"%ld",longIntNum);
vertical_print_str(printBuff);
}
//defaults to 2 digits of accuracy, unless you specify otherwise, as show in main()
vertical_print_float( double flAmt, int precision=2)
{
char printBuff[1024];
memset(printBuff,0,1024);
//writes the float value to the buffer
sprintf(printBuff,"%.*lf",precision,flAmt);
vertical_print_str(printBuff);
}
int main()
{
int b=6969;
float x=22.0f/7;
double e = exp(1);
vertical_print_str((char*) " The variable B is ");
vertical_print_int(b);
vertical_print_str((char*)" and x = ");
vertical_print_float(x,7); //outputs the value of PI vertically with 7 digits of precision
vertical_print_str((char*)" and e = ");
vertical_print_float(e); //outputs the value of E vertically with 2 digits of precision
}
Sia B.
thank you very much, I appreciate it.11/11/20