Problem with a begginer exercise

Hello,

I'm learning by myself C++ and I have to create a program that converts a cipher of seconds into minutes and hours.

This is the code I typed:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <stdio.h>

int main() {


int seconds = '?';
float minutes = '?';
float hours = '?';


printf ("How many seconds?  ");
scanf ("%d", &seconds);

seconds = seconds;
minutes = int(seconds)/60;
hours = minutes/60;

printf ("Equivalent to ");
printf ("%2d", &seconds );
printf (" seconds.\n\n");

printf ("Equivalent to ");
printf ("%2d", &minutes );
printf (" minutes.\n\n");

printf ("Equivalent to ");
printf ("%2d", &hours );
printf (" hours.\n\n");


}


And this is what I get. Completely no sense.

http://imageshack.us/a/img121/3382/huosrs.jpg

What did I do wrong?

Thank you.
Last edited on
remove the &

should look like this

1
2
3
4
5
6
7
8
9
10
11
printf ("Equivalent to ");
printf ("%2d", seconds );
printf (" seconds.\n\n");

printf ("Equivalent to ");
printf ("%2d", minutes );
printf (" minutes.\n\n");

printf ("Equivalent to ");
printf ("%2d", hours );
printf (" hours.\n\n");
Topic archived. No new replies allowed.