That is an odd rounding function.
That is an odd program altogether.
You might have better luck using a for block to increment y and then using gotoxy() to print the graph. That would get rid of a lot of useless iteration through cells that are not what you are looking for.
As for that warning, that refers to the fact that a char is a smaller unit than an int. That is, less memory is used to hold a char than an int. Thus, a large int (bigger than 255) would suffer bitwise truncation if casted as a char. The implicit cast occurs when you return a char* from a function prototyped to return an int.
That program is entirely too complicated for what you are trying to do. Try this:
Code:
#include <cstdio>
#include <conio.h>
using namespace std;
int main () {
clrscr();
signed int x = -8;
for (int xaxis = 2; xaxis<70; xaxis++) {
gotoxy(xaxis, 12);
printf("-");
}
for (int yaxis = 1; yaxis<24; yaxis++) {
gotoxy(1, yaxis);
printf("|");
}
for (x; x<9; x++) {
gotoxy(x*x + 1, 12-x);
printf("*");
}
}
I switched it to a graph of Y squared because the console is about three times as wide as it is long, but you can change it back without a lot of trouble.