Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a struct to represent a playing card. Playing cards have the following features: They have a suit . This suit can be one of

  • Write a struct to represent a playing card. Playing cards have the following features:

They have a suit. This suit can be one of the following: clubs, diamonds, hearts, spades They have a rank. Valid ranks are any number between 2 and 10 (inclusive of 2 and 10), plus ace, jack, queen, and king. Define two enums (Suit and Rank) to represent suits and ranks.

  • Write a short main function to generate a random card, and then print the card's rank and suit. Use the rand() function from the library stdlib.h

NOTE ON rand(): Before calling rand(), you must seed the random number generator.

NOTE ON rand(): rand() generates a random integer between 0 and RAND_MAX, which is a much larger number than you'll be using to generate your random cards. To get the number down to an appropriate range, use the % operator on the result from rand()

NOTE ON rand(): rand() is not the best source of randomness -- you may find it yielding predictable results, even if you correctly seed the random number generator

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

10th Edition

0137916787, 978-0137916788

More Books

Students also viewed these Databases questions

Question

Discuss the differences between services and goods AppendixLO1

Answered: 1 week ago