Same birthday

Assignment Help C/C++ Programming
Reference no: EM13165703

How likely is it that two people in one section of our class (40 students) have the same birthday ?

Suggested Approach:

  1. Prepare an integer array, a[40], to hold birthdays for 40 students.
  2. Generate a random number between 1 and 365 and assign the number to each element of a[]. Use the % operator (Example: 300%7 returns the remainder of 300 divided by 7).
  3. Compare a[0] with the rest of the students' birthdays (i.e. a[1], a[2], ..... a[22]) and if there is a match, get out of the loop, increment the counter by 1 and go to #2 (the next round of simulation).
  4. Compare a[1] with the rest of the students' birthdays (i.e. a[2], a[3], ..... a[22]) and if there is a match, get out of the loop, increment the counter by 1 and go to #2 (the next round of simulation).
  5. Compare a[2] with the rest of the students' birthdays (i.e. a[3], a[4], ..... a[22]) and if there is a match, get out of the loop, increment the counter by 1 and go to #2 (the next round of simulation).
  6. Compare a[3] with the rest of the students' birthdays (i.e. a[4], a[5], ..... a[22]) and if there is a match, get out of the loop, increment the counter by 1 and go to #2 (the next round of simulation).
  7. ¼.
  8. After n simulations, compute the value of counter/n.

Example of goto statement (to get out of the loop):

for (i=0;i<N-1;i++) for (j=i+1;j<N;j++)

   if(birthday[i]==birthday[j])

          {count++;goto ExitLoop;}

 

ExitLoop:;

.....

 

 

Reference no: EM13165703

Questions Cloud

Reason why you would not install cables : Give me two reason why you would not install cables in ducts that are used to transport dust loos stock, flammable vapors or in those ducts that are used for ventilattion for cooking?
State what is the concerntration of the weak acid : The student then titrated 25.0 ml of the same buffer with 0.1115 M NaOH. The observed titration curve is shown below
Write a c function that converts a character to upper case. : Write a C function that converts a character to upper case. The function should have the prototype char to_upper(char ch); The characters given as input to the function are assumed to be in the sets {'a', ..., 'z'} and {'A', ... , 'Z' }. Do not use a..
Network engineer for abc company : You are the network engineer for ABC company. Business is booming, a lot of new staff has been hired recently, and the company is running out of office space. A new larger building has been purchased and you have been asked to design the network f..
Same birthday : How likely is it that two people in one section of our class (40 students) have the same birthday ?
Sense the language of a : For this, sense the language of A is in the set of all languages, would showing this just involve making a DFA of one state that accepts everything? I am not sure how to show this.
State what is the standard potential of the cell : Write the cell reaction that occurs if the two Pt electrodes are shorted together. What is the standard potential of the cell?
Write a java program that prints the numbers from 1 to 125 : Write a Java Program that prints the numbers from 1 to 125. But for multiles of three print "Batman" instead of the number and for the multiples of five print "Superman". For instances which are multiples of both three and five "JusticeLeague".
State degree celcius in an adiabatic calorimeter : What must be the initial temperature of 22g of steam that is mixed with 90g of water at 68 degree celcius in an adiabatic calorimeter with a heat capacity of zero and that produces

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Calculate and display the number of units of electricity

The manager of PG&E wants a program that calculates a customer's electric bill. He will enter the current and previous meter readings.

  Prepare a program for a retail-mart company

Prepare a program for a company Retail-Mart.

  Compares the number of possible sequences

A c++ program that compares the number of possible sequences of the length L that can be generated uinder the following assumptions. Given an alphabet of size N=9. The program must output a formatted list comparing the number of possible sequences..

  Write two short c programs and solve exam-style problem

Write two short C programs and solve four exam-style problems.

  50 element array of integers with random numbers

write a java code to instantiate and initialize a 50 element array of integers with random numbers in the range of 45 through 256 inclusive.

  Ng stands for next guess

Where NG stands for next guess and LG stands for last guess. Write a function that calculates the square root of a number using this method. The initial guess will be the starting value of LG .

  Write recursive boolean method to accept array and value

Write down the recursive boolean method named isMember. The method must accept two arguments: an array and a value. Method must return true if value is found in array.

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Write a menu driven program for an online beef

Write a menu driven program for an online beef distribution company. There are 8 different

  Write a recursive definition in sml to reverse

Write a recursive definition in SML to reverse a list of elements and multiply all elements with 2.

  Program to enter number of values to be processed

Write c++ statements to permit the user to enter n, the number of values to be processed; then assign the anonymous array of n double values, storing its address in doublPtr.

  Design a deck plan space ship in eclipse

Develop a simple interactive two-dimensional spaceship deck plan editor using OpenGL and GLUT. Your program will enable a user to create and save a deck plan of a hypothetical spaceship comprising the hull walls.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd