Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

im new and i need help fast

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
i have this problem:

#include <conio.h>
#include <stdio.h>

void main()
{
int cd;
int cookies;
int pens;
int games;

printf(&quot;Enter the number of cd's you buy &quot;);
scanf(&quot;%d&quot;,&cd);

printf(&quot;Enter the number of cookies you buy&quot;);
scanf(&quot;%d&quot;,&cookies);

printf(&quot;Enter the number of pens you buy&quot;);
scanf(&quot;%d&quot;,&pens);

printf(&quot;Enter the number of games you buy&quot;);
scanf(&quot;%d&quot;,&games);

}

and when i run it i have to enter 1 on the first scanf. and the second scanf i have to enter it twice. and so on so please help.
 
I copied and paste your code and compiled run it...
3 void main()
4 {
5 int cd;
6 int cookies;
7 int pens;
8 int games;
9
10 printf(&quot;Enter the number of cd's you buy &quot;);
11 scanf(&quot;%d&quot;,&cd);
12
13 printf(&quot;Enter the number of cookies you buy &quot;);
14 scanf(&quot;%d&quot;,&cookies);
15
16 printf(&quot;Enter the number of pens you buy &quot;);
17 scanf(&quot;%d&quot;,&pens);
18
19 printf(&quot;Enter the number of games you buy &quot;);
20 scanf(&quot;%d&quot;,&games);
21 // I added this outputline
22 printf(&quot;cd: %u\ncookies: %u\npens: %u\ngames: %u\n&quot;, cd, cookies, pens, games);
23 }

and this is my result:
[mb@fs testenv]$ vi testen.c
[mb@fs testenv]$ make testen.c testen
make: Für das Target »testen.c« gibt es nichts zu tun.
cc testen.c -o testen
[mb@fs testenv]$ ./testen
Enter the number of cd's you buy 5
Enter the number of cookies you buy 8
Enter the number of pens you buy 4
Enter the number of games you buy 12
cd: 5
cookies: 8
pens: 4
games: 12
[mb@fs testenv]$

so I wonder where is your problem?
;)
netcomander
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top