I am new to programming and am following c programming for the absolute beginner. On two different programs I get this message when I run the program. Segmentation fault. What is Segmentation fault? What causes it? How do i fix it in the program listed. Thanks for the help.
Code:
#include <stdio.h>
main()
{
int x, iNumQuestions, iResponse, iRndNum1, iRndNum2;
srand(time());
printf("\nEnter number of questions to ask: ");
scanf("%d", &iNumQuestions);
for ( x = 0; x < iNumQuestions; x++ ) {
iRndNum1 = rand() % 10 + 1;
iRndNum2 = rand() % 10 + 1;
printf("\nWhat is %d x %d: ", iRndNum1, iRndNum2);
scanf("%d", &iResponse);
if ( iResponse == iRndNum1 * iRndNum2 )
printf("\nCorrect!\n");
else
printf("\nThe correct answer was %d \n", iRndNum1 * iRndNum2);
} //end for loop