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

12. Write a program using a structure that allows the user to enter the informat

ID: 3768062 • Letter: 1

Question

12. Write a program using a structure that allows the user to enter the information of company name, address, phone number, and credit rating (good or bad) for a customer. At the end, the program displays the input from the user (use 32 bytes for each member).

13. Write a program cylinder.c that accomplishes the following: Read a list of radii and heights from a file(cylinder_input.data). For each pair of values, calculate the cylinder's volume and surface area. Display the results on the screen and save the results to a file. File: cylinder_input.data 1.5 10.2 2.21 20 3 30.243 55.23 2.2 12.1 45.989 The contents of the output file “cylinder_output.data” 1.500000 10.200000 72.099551 110.269902 2.210000 20.000000 306.877054 308.404496 3.000000 30.243000 855.100680 626.615787 55.230000 2.200000 21082.525775 19929.377237 12.100000 45.989000 21153.127133 4416.305811

Part 2: From Microcontrollers Vs Microprocessors: (see slide 57 & 58 for more details)

1. Write a code that makes the MSP430 blink the red LED and the green LED at the same time. The two LEDs should be on at the same time and then off at the same time

2. Write a code that makes the MSP430 blink the red LED and the green LED in an alternating way -When the red LED is on, the green LED should be off -Inversely, when the green LED is on, the red should be off You can use the same delay as in the basic code for LED blinking- lecture note: 11-MicrocontrollersVsMicroprocessors.pdf Do not use __delay_cycles() function.

Explanation / Answer

12.

#include<stdio.h>

struct customer {

int phone_no[10],credit_rating;

String comp_name[50],address[50];

};

int main()

{

struct customer cust_id[20];

int i;

printf(“/n Enter customer Information”);

printf(“/n Enter Company name”);

gets(cust_id[].comp_name);

printf(“/n Enter address”);

gets(cust­­­­_id[].address);

for(i=1;i<20;i++)

{

printf(“Enter Phone Number:”);

scanf(“%d”,&cust_id[i].phone_no);

printf(“Enter Credit Rating:”);

scanf(“%d”,&cust_id[i].credit_rating);

}

printf(“/n Customer Information”);

for(i=1;i<20;i++)

{

puts(cust_id[i].comp_name);

puts(cust­­­­_id[i].address);

printf(“ Phone Number: %d” , cust_id[i].phone_no);

printf(“ Credit Rating: %d”, cust_id[i].credit_rating);

if(credit_rating <5)

{

printf(“BAD”);

else

printf(“GOOD”);

}

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote