What is the output from the program: pow() function and array - C++ Data Type

C++ examples for Data Type:Array

Description

What is the output from the program: pow() function and array

Demo Code

#include <iostream>
#include <cmath>
using namespace std;
int main()/*from w  ww. j a  v  a 2  s .com*/
{
   int x, y;
   char label[] = "                      y axis";
   char axis[] = "+---------------------------------------------------->";
   char line[] = "|                                                ";
   cout << label << endl;
   cout << axis << endl;
   for (x = 1; x <= 15; x++)
   {
      y = pow((x-8),2.0) + 3;
      line[y] = '*';           // set character to an asterisk
      cout << line << endl;     // output the line
      line[y] = ' ';           // reset character to a blank
   }
   return 0;
}

Result


Related Tutorials