Bir para 100 kere havaya atılıyor ve kaç kere yazı kaç kere tura gelmiş onu hesaplıyor. her atışın sonucunuda ekrana yazdırmayı ihmal etmiyor 🙂


#include <stdio.h>
#include <stdlib.h>
int flip();
main(){
randomize();
int cnt=1;
int heads=0,tails=0;
while(cnt<=100)
{
if(flip()){
printf(“Heads “);
heads=heads+1;}
else{
printf(“Tails “);
tails=tails+1;}
cnt=cnt+1;
}
printf(”
Total number of Heads was %i”,heads);
printf(”
Total number of Tails was %i”,tails);
}
int flip()
{
int x;


x=rand()%2;
if(x==1)
return 1;
else
return 0;
}


Kaynak: Doğu Akdeniz Univ. CSIT Labworks
belgesi-430
Belgeci

Share
Published by
Belgeci

Recent Posts

İlk Cep Telefonu

ÖZELLİKLER: Boyut: 28x8x6 cm Ağırlık: 850gr Ekran: Yok Devre sayısı: 30 Konuşma süresi: 35 dakika…

11 saat ago

Basic Grammar-Questions

There are two kinds of questions: yes or no questions and wh- questions. You ask…

23 saat ago

Basic Grammar-Positive And Negative Sentences

A positive sentence tells you that something is so. A sentence that tells you something…

1 gün ago

Basic Grammar-The Imperative

Use the base form of a verb to give commands or make direct requests. This…

2 gün ago

Basic Grammar-Sentences

A sentence is a group of words that expresses a complete thought. A sentence must…

2 gün ago

Basic Grammar-Interjections

An interjection is a word that expresses a sudden, strong feeling such as surprise, pain,…

3 gün ago