This is a discussion on Please help me with this simple code. newbie here. within the C Programming forums, part of the General Programming Boards category; Yes this is hw and i have done 47 out of 50 of the problems. I have just gotten stuck ...

Yes this is hw and i have done 47 out of 50 of the problems. I have just gotten stuck on these last 3. if anyone is in the mood to help. please do. I am willing to take pointers as well to help me get along thx.

1. Given an int variable n that has already been declared and initialized to a positive value, and another int variable j that has already been declared, use a while loop to print a single line consisting of n asterisks. Thus if n contains 5, five asterisks will be printed. Use no variables other than n and j.
i have no idea where to begin

2. Given int variables k and total that have already been declared, use a while loop to compute the sum of the squares of the first 50 whole numbers, and store this value in total. Thus your code should put 1*1 + 2*2 + 3*3 +... + 49*49 + 50*50 into total. Use no variables other than k and total.

i tried this but didnt work?

.
Code:
```while(k<=50){
total=total+k^2;
k=k+1;```

and 3. Given an int variable k that has already been declared, use a do...while loop to print a single line consisting of 97 asterisks. Use no variables other than k.

i tried

Code:
```do {
printf("*");
} while (k<98);```

thanks so much you guys are great.

2. lol

what were your previous 47 questions? Learning how to write helloworld in 47 different languages?

If you have done those 47 then this should be a catwalk.
Code:
```1. if n =1, j=5;

while(n<j)
printf('*');

2. you cant do k^2
total=0;
k=1;
while(k<=50){
total=total+k*k;
k++;
}```

3. ## the first one doesnt work?

The first answer u gave me was wrong.
it has to print as many stars as the number the user enters.

And i still need help with the 3rd one

4. >And i still need help with the 3rd one
Code:
```k=0;
do {
printf("*");
k++;
} while(k<97);```