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
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started