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

1. (35 pts) Rewrite the following program using macro definitions (tdefine) for

ID: 3725734 • Letter: 1

Question

1. (35 pts) Rewrite the following program using macro definitions (tdefine) 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;): K) if (selectedCard 11 selectedCard'Q selectedCard lelse if (selectedCard5'&& selectedCard10) else if (selectedCard1) ) else printff"You earn 10 points In") printf "You earn 2 ptsIn") printf"You earn 20 pts n") printf"No cheating allowed. You earn 0 ptsIn") 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 O 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

2)

#include <stdio.h>

int main(void) {

char arr[5];

for(int i=77;i<82;i++)

{

arr[i]=i;

printf("%c",arr[i]);

}

return 0;

}

3)

#include <stdio.h>

int main(void) {

int arr[3][10];

int j=0;

for(int i=0;i<3;i++)

{

arr[i][0]=7;

printf("%d",arr[i][0]);

for(int j=1;j<10;j++)

{

arr[i][j]=0;

printf("%d",arr[i][j]);

}

printf(" ");

}

return 0;

}

4)

#include <stdio.h>
#include <ctype.h>
char big(char );
int main() {
char ch;
printf("Enter the character :");
scanf("%c",&ch);
char ch1=big(ch);
printf("%c",ch1);
return 0;
}
char big(char ch)
{
if(ch>=97 && ch<=122)
{
return toupper(ch);
}
else
return ch;
}