I need help with an x-y plot. - write a program to create a simple plot of the e
ID: 3641951 • Letter: I
Question
I need help with an x-y plot.- write a program to create a simple plot of the equation x=y2
the y value should be on the vertical axis and go from 5 to -5 in increments of one. Use an appropriate looping structure. the plot should appear as shown below;
5| *
4| *
3| *
2| *
1| *
0|*
-1| *
-2| *
-3| *
-4| *
-5| *
I need to have this written in C programming language.
I have tried this (program below) but it is not compiling correctly.
#include<stdio.h>
#include<stdlib.h>
int main(void)
{
int i, j;
for(i=5; i>-6; i--)
printf("%2d| ; i);
for(j=0; j<(i*i); j++)
printf("%c" ' ' ');
printf("%c ", '*');
}
system("PAUSE");
return 0;
Explanation / Answer
#include<stdio.h>
#include<stdlib.h>
int main(void)
{
int i, j;
for(i = 5; i > -6; i--)
{
printf("%2d|", i);
for(j = 0; j < (i*i); j++)
printf("%c", ' ');
printf("%c ", '*');
}
getchar();
return 0;
}
http://codepad.org/sC68FeoP
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.