quiz code not working/out of ideas

Hello People! This is my first forum topic and from the looks of it it will not be the last one. Anyway, my assignment is to build a questionaire game show. My idea was to make every correct answer 25 points and incorrect ones zero.
Under the main function I asked the user his/her name and asked whether she/he was ready to play or not. After the main function comes sorubir, soruiki and so on. Is it possible to sum up return values of functions and then display it at the end under the main function. Feel free to ask for any translations if its making your job any more difficult. (Dogru cevap = correct answer, yanlis = wrong.)
Thank you in advance!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
  #include <stdio.h>

char kullanici[30];
int hazir;
int soru1;
int soru2;
int soru3;
int soru4;
int sonuc;
int degerlendirme;


int main() {
	
	printf("Merhaba kullanici. Ismini bizimle paylasirmisin?");
	scanf("%s", kullanici);
	printf("Bilgi yarismasina hazirmisin peki %s? 1=evet 2=hayir", kullanici);
	scanf("%d", &hazir);
	
	if (hazir==1)
		printf("O zaman ilk sorun gelsin");
	else if (hazir==2)
		printf("O zaman neden calistirdin kodu?");
		
	


int sorubir() {

	printf("Turkiyenin baskenti neresidir?\n");
	printf("1) Istanbul\n");
	printf("2) Izmir\n");
	printf("3) Bayburt\n");
	printf("4) Ankara\n");
	scanf("%d", &soru1);

	if (soru1==4)
	{
			printf("Dogru cevap!");
			return 25;}
	else
	{
			printf("Yanlis cevap..");
		return 0;}
	
}
int soruiki()
{
	
	printf("Turkiye Cumhuriyetinin kurucusu kimdir?\n");
	printf("\n1)Mustafa Kemal ATATURK");
	printf("\n2)Ahmet Necdet Sezer");
	printf("\n3)Abdullah Gul");
	printf("\n4)Recep Tayyip Erdogan");
	scanf("%d", &soru2);
	
	if (soru2==1)
		{
		printf("Dogru Cevap!");
			printf("Ilginc bir detay; bu sorunun cevabini bilmeyenler var!");
			return 25;}
	else 
		{
		printf("Yanlis.. cok yanlis..");
				return 0;}

}
int soruuc() 
{
	
	printf("1+1+1+1+1+1+1+1*0+1 in cevabi nedir?");
	printf("\n1)Sifir");
	printf("\n2)Sekiz");
	printf("\n3)Bir");
	printf("\n4)Hicbiri");
	scanf("%d", &soru3);
	
	if (soru3==2)
		{
		printf("Dogru cevap!");
			return 25;}
	else 
		{
		printf("Yanlis cevap..");
			return 0;}
	
}
int sorudort() 
{
	
	printf("Son sorumuz geliyor!\n");
	printf("Bil 143 kodlu dersi veren hocanin adi\n");
	printf("ve dersin verildigi sinif neresidir?\n");
	printf("1)Adem Sahin, Kirmizi amfi\n");
	printf("2)Adem Sahin, Mavi Amfi\n");
	printf("3)Oguz Hanoglu, Mavi amfi\n");
	printf("4)Oguz Hanoglu, Kirmizi amfi\n");
	scanf("%d", &soru4);
	
	if (soru4==3)
		{
		printf("Dogru cevap!!!");
			return 25;}
	else 
		{
		printf("Yanlis cevap..");
			return 0;}
	
}
 	soru1+soru2+soru3+soru4 = sonuc
 	
 		printf("%d", &sonuc)
	
	return 0;
}
It is possible, but you have to assign it to a variable, or total the function calls.

For example, you could do the following in your main function:

(beginning)
int Q1, Q2, Q3, Q4, total = 0;
...
...
...
(if you want to play)
Q1 = sorubir();
Q2 = soruiki();
Q3 = soruuc();
Q4 = sorudort();

(exit if statement)
total = Q1 + Q2 + Q3 + Q4;
printf("Total is: %d\n", total);
(end)

Another problem with your code is that all of your functions come after the main function. If you are going to do that you have to prototype, which means putting all the function definitions above the main. For example the prototype for the sorubir function would be:

int sorubir();

you would do the same with the other functions, putting it above the main function. OR you can just move all of your functions above the main() function.

Hope this helps!
Topic archived. No new replies allowed.