(adsbygoogle = window.adsbygoogle || []).push({}); 1. The problem statement, all variables and given/known data

Hi, I'm writing a c++ code which is about making an xy plane with dots and then using an array an plot a math function with a character. the functions i need to plot are sin x, sqrt x and a polynomial. so far I attempted to make a function for plotting sin x, but I always get it wrong, so I was wondering if anyone here help me out. also if i can have a clue of how i could go about the other function. thanks.

2. Relevant equations

3. The attempt at a solution

#include <iostream>

#include <cmath>

using namespace std;

const int Row = 21;

const int Col = 76;

const double PI = 3.14159;

int main()

{

char A[Row][Col];

for (int x=0 ; x < Row ; x++)

{

for (int y=0 ; y < Col ; y++)

{

A[x][y] = '.';

}

}

for (int i=0 ; i < Row ; i++)

{

for (int j=0 ; j < Col ; j++)

{

cout << A[j];

}

cout << "\n";

}

for(int q = 0; q < Row; q++)

{

for(int w = 0; w < Col; w ++)

{

w = 3.5 sin((double)PI* q);

A[q][w] = 'o';

}

}

for( int s = ( Row - 1); s >-1 ; s--)

{

for( int t = 1; t<Col; t++)

{

cout<< A;

cout<<endl;

}

}

return 0;

}

sin x would be plotted showing 'o' on the dots.

**Physics Forums | Science Articles, Homework Help, Discussion**

Dismiss Notice

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Homework Help: C++ question

**Physics Forums | Science Articles, Homework Help, Discussion**