Quellcode Zusatzaufgabe 6

Dieses Programm sucht sich eine Zufällige Zahl aus, die der Benutzer dann erraten muss.

/* * * * * * * * * * * * * * * * 
* Name: Christian Klisch *
* Klasse: ITA 1b *
* Datum: 14.02.2000 *
* Dateiname: AUFZ6.c *
* Zweck: Zufallszahlen *
* * * * * * * * * * * * * * * */

#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<dos.h>

void main()
{
//Deklaration
int zufallszahl,eingabe,wiederhlung,zahl,i,random;

//Programmstart
clrscr();
printf("Erraten einer Zufallszahl\n\n Bitte geben Sie eine Zahl ein:\n");
zahl=0;
i=1;

randomize();

//Zufallszahl
zufallszahl=random(20);
printf("%d\n",zufallszahl);
getch();

//Schleife
do{
gotoxy(1,5);
clreol();
printf("\n");
clreol();
printf("\n");
clreol();
printf("\n");
clreol();
printf(" ");
gotoxy(1,5);

printf("\nVersuch %d\n Zahl: ",i);
fflush(stdin);
scanf("%d",&eingabe);

//Verzweigung nach Zahl
if(zufallszahl!=eingabe)
{
if(eingabe<zufallszahl)
{printf(" Zu Klein\n");}
else
{printf(" Zu Groá \n");}

delay(500);
}
else
{
printf("\n ");
zahl=1;

}
i++;
}while(zahl==0);
printf("\n\nRichtig, die Zahl war %d\n Erraten nach %d Versuchen",zufallszahl,i-1);
getch();
}

Home << Schule << ITA-Mappe << Softwareentwicklung und Anmendung <<
Online: 1 | IP: | 29.03.2024 - 12:15:51  
©
Christian Klisch   - Alle Rechte vorbehalten - Impressum