Write a function that will calculate either the area of a square or the volume o
ID: 3855517 • Letter: W
Question
Write a function that will calculate either the area of a square or the volume of a cube based on the parameters passed to it. If only length and width are passed, the height should default to one using a default parameter. The function should use the same formula to calculate both quantities. The result should be returned in a tuple with the second part being the units (we will use feet to be consistent between everyone's code). Ex: calc(2, 5) would return (10, 'sq ft) calc(2, 5, 3) would return (30, 'cu ft') Write a program to play a very modified version of spades. The program will select two hands of 5 cards for a single player and the computer dealer. The hands should be chosen using a function and the random methods we discussed in class. Your function should check the cards to be sure that they have not been used in the other hand. If so, then another card will be chosen at random until a hand can be formed. After the second hand is dealt, all cards are available again. A winner of the game will be chosen based on the sum of all cards in the hand. The sum of the cards will be calculated as follows: 2, 3, 10-face value Jacks = 11 Queens = 12 Kings = 13 Aces = 14 The suit of the cards is used as a multiplier. Spades are worth 2 times the face value giving an advantage to any hands containing spades. All other suits are worth face value onlyExplanation / Answer
1.question answer
#include<stdio.h>
void main()
{
int l,b,h,fig_code,k,v;
printf("1--> area of square/n")
printf("2-->volume of cube/n");
printf("enter length,breath,height values/n");
scanf("%d%d%d",&l,&b,&h);
printf("enter fig_code);
scanf("%d",fig_code);
switch(fig_code)
{
case 1:
k=i*b; //k=2*5=10
scanf("%d",k);
printf(k,"sq ft"); //(10,'sq ft')
case 2:
v=i*b*h; //v=2*5*3=30
scanf("%d",v);
printf(v,'cu ft'); //(30,'cu ft')
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.