From the course: C: Data Structures, Pointers, and File Systems
Unlock the full course today
Join today to access over 22,500 courses taught by industry experts or purchase this course individually.
Challenge: Lotto simulation - C Tutorial
From the course: C: Data Structures, Pointers, and File Systems
Challenge: Lotto simulation
(techno music) - [Instructor] Thanks to your C programming skills, you no longer need to find your winning lotto numbers inside a fortune cookie. Your challenge is to write your own lotto number drawing program. This code has four parts. First comes initialization, second, pulling the lotto numbers, third, sort the winning numbers lowest to highest, and fourth, display the results. Now, for the details. Set the number of lotto balls to 51. This value indicates the range of numbers from one to 51. Set the number of balls to draw at six, so the winning numbers will be in the range of one to 51, and there will be six of them. Here are some hints to help you. Devise a way to keep track of the lotto numbers drawn. That way, you don't accidentally draw the same number multiple times. Your solution will probably involve one or more arrays. While you can use pointers to help keep track of the numbers, it's not necessary. I recommend setting constant expressions for the number of balls, 51…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
(Locked)
Solving math puzzles3m 32s
-
(Locked)
Creating random numbers3m 42s
-
(Locked)
Working with time functions3m 54s
-
(Locked)
Sorting data4m 8s
-
(Locked)
Debugging your code2m
-
(Locked)
Using a debugger4m 53s
-
(Locked)
Writing your own header file2m 53s
-
(Locked)
Mixing multiple source code files4m
-
(Locked)
Challenge: Lotto simulation1m 18s
-
(Locked)
Solution: Lotto simulation2m 29s
-
(Locked)
-