Link to home
Start Free TrialLog in
Avatar of Doomtomb
Doomtomb

asked on

REALLY EASY I don't know why this won't enter the for loop

I keep getting compiling errors on this and I'm about ready to throw my first right through the screen of this laptop.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
 
int main( void )
{
	int quantity = 1;
	int i = 1;
	srand(time(NULL));
 
	printf( "How many Quick Picks do you want?\n" );
	scanf( "%d\n", &quantity );
 
	for ( i = 1; i <= quantity i++ ) 
	{
		printf( "Quick Pick: %d\n", 1 + (rand() % 54));
	}
			
	return 0;  /* program executed successfully */
}

Open in new window

Avatar of sunnycoder
sunnycoder
Flag of India image

for ( i = 1; i <= quantity; i++ )
note ; after quantity
Avatar of Doomtomb
Doomtomb

ASKER

Jeeze, I knew it was something dumb like that. I have attached what it is right now but for some reason, it won't enter the for loop. It prints asking the user, then you type a value like 2 and enter and nothing happens.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
 
int main( void )
{
	int quantity;
	int i;
	srand( time( NULL ) );
 
	printf( "How many Quick Picks do you want?\n" );
	scanf( "%d\n", &quantity );
 
	for ( i = 1; i <= quantity; i++ ) {
		printf( "Quick Pick: %d\n", 1 + (rand() % 54));
	}
			
	return 0;  /* program executed successfully */
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of sunnycoder
sunnycoder
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Works great. My programming teacher forces us to use scanf. It sucks. I HATE THIS!!!!! I GOT SO MAD!!!!!!! THANK YOU!!!!!! *ANGRY VOICE*