Question: Can you help me answer the following C programming question based on the following sample code. Sample code: #define _CRT_SECURE_NO_WARNINGS #include #include struct Person {

Can you help me answer the following C programming question based on the following sample code.

Sample code:

#define _CRT_SECURE_NO_WARNINGS #include #include

struct Person { int age; char job; char own_house; char credit[15]; };

void confirmation(struct Person person) { int select;

if (person.age >= 18 && person.age <= 35) select = 0;

else if (person.age >= 36 && person.age <= 55) select = 1;

else if (person.age > 55) select = 2;

switch (select) { case 0: { if (person.job == 'y') printf(" Approved"); else printf(" Not Approved"); break; } case 1: { if (person.own_house == 'y') printf(" Approved"); else printf(" Not Approved"); break; } case 2: { if (!strcmp(person.credit, "fair")) printf(" Not Approved"); else printf(" Approved"); } } }

int main() { struct Person person;

printf("------------ Credit Card Application ------------ "); printf("Enter your age : "); scanf("%d", &person.age); printf("Do you have a job? "); scanf(" %c", &person.job); printf("Do you own a house? "); scanf(" %c", &person.own_house); printf("Enter the Credit rating: "); scanf(" %s", &person.credit);

for (int i = 0; i <= strlen(person.credit); i++) { // convert the credit string into lower case if (person.credit[i] >= 65 && person.credit[i] <= 90) person.credit[i] = person.credit[i] + 32; }

confirmation(person);

return 0; } output:

--------Credit card application -------

Enter your age: 30

do you have a job: y

Do you own a house: n

enter the credit rating: fair

Questions:

1. How many functions did you write to complete the assignment? If you created more functions than just main, how did this benefit your program. If you put everything in main, would there be a benefit of using additional functions and, if so, what would be the benefit?

2. How do you read answers that might be upper case or lower case and figure out what they user really means?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!