Image

Imageotakuchibijosh wrote in Imagecprogramming 😡frustrated

I'm a new member here, and I need a little help. I'm an engineering major at WVU, and I'm in a C programming class.
I have some homework due tomorrow, and I've been working on it for 2 days, and trying to get it to work with no luck. The basic idea of the program is that a square of a number, n is calculated bu adding n number odd integers together. (i.e. 5^2 = 1 + 3 + 5 + 7 + 9 = 25). The full explanation is right here: http://www.csee.wvu.edu/~michaelk/ENGR102/Homework/homework1.pdf



#include
[Error: Irreparable invalid markup ('<stdio.h>') in entry. Owner must fix manually. Raw contents below.]

I'm a new member here, and I need a little help. I'm an engineering major at WVU, and I'm in a C programming class.
I have some homework due tomorrow, and I've been working on it for 2 days, and trying to get it to work with no luck. The basic idea of the program is that a square of a number, <i>n</i> is calculated bu adding <i>n</i> number odd integers together. (i.e. 5^2 = 1 + 3 + 5 + 7 + 9 = 25). The full explanation is right here: http://www.csee.wvu.edu/~michaelk/ENGR102/Homework/homework1.pdf


<lj-cut>
#include <stdio.h>
#include <math.h>

int main(void)
{
int x=1;
int square;

printf("Enter a value you wish to have squared.\n\a Press 0 to stop.\n\a");

scanf("%i", &square);

switch (square)
{
case 0:

break;

default:

while(x < square*square)
{
x=x+2;
}

printf("the square of %i is %i.\a\n", &square, &x);

break;
}



return 0;

}

<b><center>******************</b></center>
Right now, I need help as to why this isn't working. The scanf command isn't even working. It just displays "Enter a value you wish to have squared.\n\a Press 0 to stop." and does nothing else.</lj-cut>

Thanks!