Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

REWrite the following program using macro definitions (#define) for all the cons

ID: 3349460 • Letter: R

Question

REWrite the following program using macro definitions (#define) for all the constants and a new type definition (typedef) called Card for all the values representing the value of cards. #include int main(void) { char selectedCard; printf(“Choose a card ”); scanf(“%c”, &selectedCard); if (selectedCard == ‘J’ || selectedCard == ‘Q’ || selectedCard == ‘K’) { printf(“You earn 10 points ”); } else if (selectedCard >= ‘5’ && selectedCard <= ‘10’) { printf(“You earn 2 pts ”); } else if (selectedCard == ‘1’) { printf(“You earn 20 pts ”); } else { printf(“No cheating allowed. You earn 0 pts ”); } return 0; } 2. (25 pts) Declare a character array of size 5. Write a loop to initialize the array with consecutive letters starting at the letter 'M' 3. (15 pts) Declare a two dimensional int array of size 3 x 10 (row x column) and initialize the first element of every row to 7 and the remaining elements to 0 at the same time of declaration. 4. (25 pts) Write a function that takes a character as input and returns it in uppercase. If the character is uppercase or not an alphabet letter, the function should return the same character without changing IT

Explanation / Answer

#include <stdio.h>

#define KVALUE 'K'

#define JVALUE 'J'

#define QVALUE 'Q'

' #define FIVE 'K'

#define TEN 'K'

#define ONE '1'

int main(void)

{

typedef char Card;

Card selectedCard;

printf("Choose a card ");

scanf("%c", &selectedCard);

if (selectedCard == JVALUE|| selectedCard == QVALUE ||selectedCard == KVALUE)

{

printf("You earn 10 points ");

}

else if (selectedCard >= FIVE && selectedCard <= TEN)

{

printf("You earn 2 pts ");

}

else if (selectedCard== ONE)

{

printf("You earn 20 pts ");

}

else

{

printf("No cheating allowed. You earn 0 pts ");

}

return 0;

}