![]() |
Basit Bir Carpma Oyunu CPP Bilgisayar size 1′le 10 arasında iki sayıyı random olarak seçip çarpımlarını soruyor. Doğru bilirseniz random olarak bir tebrik mesajı veriyor. Bilemezseniz random olarak hata mesajı veriyor. #include <stdio.h> #include <stdlib.h> void multiplication(void); void correct(void); void incorrect(void); main() { int answer=0; while (answer!=(-1)) { multiplication(); printf(“do you want to countinue”); scanf(“%i”,&answer); } } void multiplication(void) { int x,y,z; randomize(); x=rand()%10; y=rand()%10; printf(“how much is %i times %i “,x,y); cevapal:scanf(“%i”,&z); if(z==(x*y)) { correct(); } else{ incorrect(); goto cevapal; } } void correct(void) { int k; randomize(); k=rand()%3; if(k==0) printf(“Very Good”); else if (k==1) printf(“Excellent!”); else if (k==2) printf(“Nice work!”); else if (k==3) printf(“Keep up the good work”); } void incorrect(void) { int c; randomize(); c=rand()%3; if(c==0) printf(“No. Please try again”); else if (c==1) printf(“Wrong Try once more”); else if (c==2) printf(“Don’t give up!”); else if (c==3) printf(“No. Keep trying”); } Kaynak: Doğu Akdeniz Univ. CSIT Labworks belgesi-413 |
| Tüm Zamanlar GMT +3 Olarak Ayarlanmış. Şuanki Zaman: 22:26. |
Powered by vBulletin® Version 3.8.9 Copyright ©2000 - 2026, vBulletin Solutions, Inc.
Site kurucuları: Damla ve Meltem