0

what is the problem actually in my code?when debug ,it will crash or come out same data.

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main(void)
{
	int col;
	int rand_question[3];
	int confirm_question[3];
	int i;
	int score=0;
	char choice;
	int max_question, total_question;

	max_question = 3;
	total_question = 3;

	srand(time(NULL));

	
	/for(col=0 ; col < max_question ; col++)
	{
		if(col==0)
		{
			confirm_question[col] = rand() % total_question ;
		}
		else
		{
			do
			{
				rand_question[col] = rand() % total_question;
			
				for(i=1 ; i < col ; i++)  
				{
					if(rand_question[col] == confirm_question[i]||rand_question[col]==0)
					{
						break;
					}
				}
			}while(rand_question[col] == confirm_question[i]);
			
			confirm_question[col] = rand_question[col];
		}

	}
	
	system("cls");
	  
	for(i=0; i<3; i++)
	{
		printf("%d\n",confirm_question[i]);
	}

		for(i=0; i<3; i++)
		{
			switch(confirm_question[i])
			{
				case 1:
					score=quizquestion1();
					break;
				case 2:
					score=quizquestion2();
					break;
				case 3:
					score=quizquestion3();
					break;
				default:
					printf("Nothing\n\n");
					break;
			}
				
		}

	
		printf("\t******************************************************************************\n");
		printf("\t*       Thanks for your answering  Your final score are %d/10  \n\n          *",score);
		printf("\t******************************************************************************\n");
		
	return 0;
}

1>c:\users\lenovo\documents\visual studio 2010\projects\chemquiz\chemquiz\quiz.c(33): error C2449: found '{' at file scope (missing function header?)
1>c:\users\lenovo\documents\visual studio 2010\projects\chemquiz\chemquiz\quiz.c(512): error C2059: syntax error : '}'
1> game.c
1>c:\users\lenovo\documents\visual studio 2010\projects\chemquiz\chemquiz\game.c(29): warning C4244: 'function' : conversion from 'time_t' to 'unsigned int', possible loss of data
1>c:\users\lenovo\documents\visual studio 2010\projects\chemquiz\chemquiz\game.c(64): error C2059: syntax error : 'return'

2
Contributors
1
Reply
3
Views
5 Years
Discussion Span
Last Post by WaltP
0

what is the problem actually in my code?when debug ,it will crash or come out same data.


1>c:\users\lenovo\documents\visual studio 2010\projects\chemquiz\chemquiz\quiz.c(33): error C2449: found '{' at file scope (missing function header?)
1>c:\users\lenovo\documents\visual studio 2010\projects\chemquiz\chemquiz\quiz.c(512): error C2059: syntax error : '}'
1> game.c
1>c:\users\lenovo\documents\visual studio 2010\projects\chemquiz\chemquiz\game.c(29): warning C4244: 'function' : conversion from 'time_t' to 'unsigned int', possible loss of data
1>c:\users\lenovo\documents\visual studio 2010\projects\chemquiz\chemquiz\game.c(64): error C2059: syntax error : 'return'

It all depends on what is on or before lines 33 and 512 in quiz.c and lines 29 and 64 of game.c

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.