heya..
im creating a quiz program...but i dont konw how to randomize the questions
can any1 help me out???

If you have 50 questions, the following code will print 10 numbers within the range of 0 to 50. The same number may get printed multiple times, but you can get rid of that by modifying the code to re-loop if an already printed number is obtained.

srand( time(NULL) );
   for( i = 0; i < 10; i++ )
     printf( "Random number #%d: %d\n", i, rand()%50 );

what would be the equivalent c++ code

since printf() is a c function I can;t understand it :)

would be nice if you tell me the c++ thanks

Haven't you written at least a "Hello World" program in C++ ?

If you have 50 questions, the following code will print 10 numbers within the range of 0 to 50. The same number may get printed multiple times, but you can get rid of that by modifying the code to re-loop if an already printed number is obtained.

srand( time(NULL) );
   for( i = 0; i < 10; i++ )
     printf( "Random number #%d: %d\n", i, rand()%50 );

Within the range of 0 to 49.

commented: Thanks for pointing that out. +6

Hmm. Yeah. I felt something was not right there. Thanks.

since printf() is a c function I can;t understand it :)

Sure you can. It's obvious if you think about it.

hi guys,
im still a student,
taking up It course,
can you help me?
how to create a quiz game program?^^

This thread is really old. You could make a new one or / and above all read carefully what was said then.

What is your problem, then? You have some tips above. Have you any idea how to write at least 'hello-world' programs? If not, start from beginning. And show us that you've tried sth.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.