# Coin Tossing Simulation

Subject Computer Science C-Family Programming

## Question

Write a program that simulates coin tossing. For each toss of the coin the program should print Heads or Tails. Let the program toss the coin 100 times, and count the number of times each side of the coin appears. Print the results. The program should call a separate function flip that takes no arguments and returns 0 for tails and 1 for heads. [Note: If the program realistically simulates the coin tossing, then each side of the coin should appear approximately half the time for a total of approximately 50 heads and 50 tails.]

## Solution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

/*Define and Includes */
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

// Declare the coinflip function
int coinFlip(void);

// Main Function
int main()
{
// Declaring variables
int toss;
int numOfTails = 0;
int result=0;
// srandom process
srand(time(NULL));
// Toss Loop
for (toss = 1; toss <= 100; toss = toss + 1)
{
// Return the result of the coin flip
result=coinFlip();
switch (result)
{...

This is only a preview of the solution. Please use the purchase button to see the entire solution

## Related Homework Solutions

C++ Programming Problems \$20.00
Computer Science
C++ Programming
Users
Lists
Structures
Arrays
Vectors
Functions
Elements
Members
Printing
Prototypes
Linear Search
Arrays and Vectors in C++ \$13.00
Computer Science
C++ Programming
Arrays
Vectors
Animals
Data Storage
Names
Items
Lists
Statements
Variables
Library Application in C++ \$20.00
Computer Science
C++ Programming
Library Application
Classes
Books
Members
Attributes
Statements
Conditions
Constructors
Variables
Objects
Methods
C Programming Problems \$25.00
Computer Science
C Programming. Students
Courses
Average Values
Integers
Numbers
Database Systems
Points
Coordinates
Commands
ASCII Art in C++ \$23.00
Computer Science
C++ Programming
ASCII Art
Learning Algebra
Random Values
Buildings
Floors
Equations
Games
Winning
Lines
C++ Programming Problems \$8.00
Computer Science
C++ Programming
Functions
Leaves
Trees
Loops
Levels
Numbers
Users
Iterations
Statements
Variables
Odd Values
Live Chats
{"ft_lang_label":"__label__en","ft_lang_prob":0.7946645,"math_prob":0.6340425,"size":1384,"snap":"2020-24-2020-29","text_gpt3_token_len":318,"char_repetition_ratio":0.1326087,"word_repetition_ratio":0.008733625,"special_character_ratio":0.24421965,"punctuation_ratio":0.12109375,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.95178664,"pos_list":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14],"im_url_duplicate_count":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-05-28T01:28:17Z\",\"WARC-Record-ID\":\"<urn:uuid:716fb706-6f53-4d96-97bb-f08783dc9938>\",\"Content-Length\":\"55230\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:5190e2a2-12a3-4364-b80a-fb372d2ba114>\",\"WARC-Concurrent-To\":\"<urn:uuid:8767d764-533f-4c19-bbbf-e80a75a1cc21>\",\"WARC-IP-Address\":\"54.165.236.111\",\"WARC-Target-URI\":\"https://www.24houranswers.com/college-homework-library/Computer-Science/C-Family-Programming/37333\",\"WARC-Payload-Digest\":\"sha1:ZKFRVO4OXJYUV5HDS6EMNYGMD3CPG4AE\",\"WARC-Block-Digest\":\"sha1:S2PVQQ4O2L7RT5I3R4GHRKGI5XQYSBMR\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-24/CC-MAIN-2020-24_segments_1590347396300.22_warc_CC-MAIN-20200527235451-20200528025451-00248.warc.gz\"}"}