# Thread: Newbie in need of help

1. ## Newbie in need of help

I'm doing homework right now, and it wanted me to do this.
Code:
```Sphere ( 1)      R = 1.10      A =  15.2053      V =   5.5753
Sphere ( 2)      R = 1.20      A =  18.0956      V =   7.2382
...........      ........      ............      ............
...........      ........      ............      ............
Sphere (20)      R = 3.00      A = 113.0973      V = 113.0973```
The first one is just the sphere's name, second column is the sphere's radius, third is its area with that radius, and fourth is the volume.

I'm pretty sure I can do most of the programming, but I don't understand two things.

1) How do you get the numbers to go up by in the sphere and R = ? (R is going up by .1! I only learned how to increment it by 1)

2) How do I number the spheres with two characters?
Like
Code:
`Sphere( 1)`
Not
Code:
`Sphere(1)`
?

Much thanks guys, this looks like a very helpful site.

Code:
`for(double R = 1.0; R < 3.0; R += .1)`
This example has parentheses only to demonstrate it. The %2d specifies a field of width 2.

Code:
`printf("(%2d) (%2d)", 1, 11);`

3. If you only need 1 digit of accuracy, and you don't need huge numbers, you can represent them as ints, only 10 times larger, then convert back at run-time for display/calculations.

4. This example has parentheses only to demonstrate it. The %2d specifies a field of width 2.

Code:
`printf("(%2d) (%2d)", 1, 11);`
[/QUOTE]

I get this as a result.

Code:
`Sphere ( 1) (11)Sphere ( 1) (11)Sphere ( 1) (11)Sphere ( 1) (11)Sphere ( 1) (11)`
etc... How do I get it to go down like the example below? *I'm using SSH Secure Shell since it's a required program*

Code:
```Sphere ( 1)
Sphere ( 2)
Sphere ( 3)
Sphere ( 4)
Sphere ( 5)```
Much thanks.

5. Just by slightly modifying my code.

Code:
```int main()
{
for(int i = 1; i <= 5; i++)
{
printf("Sphere (%2d)\n", i);
}
}```

6. Much thanks for the help Tonto, it worked! This is a bit harder than I thought. I think I can handle it from here.

7. Yep, I'm back.

I've been making really slow, but sure progress, but now I'm stuck.

Code:
```{
int i;
int k;

for(i=1; i<21; i++)
for(k=1; k<21; k++)
{
printf("Sphere (%2d)     Area = %2d\n", i, k);

}
}```
This gives me...

Code:
```Sphere ( 1)     Area =  1
Sphere ( 1)     Area =  2
Sphere ( 1)     Area =  3
Sphere ( 1)     Area =  4
Sphere ( 1)     Area =  5
Sphere ( 1)     Area =  6
Sphere ( 1)     Area =  7
Sphere ( 1)     Area =  8
Sphere ( 1)     Area =  9
Sphere ( 1)     Area = 10
Sphere ( 1)     Area = 11
Sphere ( 1)     Area = 12
Sphere ( 1)     Area = 13
Sphere ( 1)     Area = 14
Sphere ( 1)     Area = 15
Sphere ( 1)     Area = 16
Sphere ( 1)     Area = 17
Sphere ( 1)     Area = 18
Sphere ( 1)     Area = 19
Sphere ( 1)     Area = 20
Sphere ( 2)     Area =  1
Sphere ( 2)     Area =  2
etc...```
How would I avoid the spheres being repeated 20 times? And how would I make it like the example below?

Code:
```Sphere ( 1)     Area = 1
Sphere ( 2)     Area = 2
etc...```
Sorry for so many Questions.

8. Because you should be performing some kind of calculation for each sphere
Code:
```for(i=1; i<21; i++)
{
printf("Sphere (%2d)     Area = %d\n", i, i*i);
}```
Note that i*i is not the function for calculating the surface area of a sphere, that's for you to research.