Question: C Programming 1. Add each element in origList with the corresponding value in offsetAmount. Print each sum followed by a space. Ex: If origList =

C Programming

1. Add each element in origList with the corresponding value in offsetAmount. Print each sum followed by a space. Ex: If origList = {4, 5, 10, 12} and offsetAmount = {2, 4, 7, 3}, print:

6 9 17 15 

#include

int main(void) { const int NUM_VALS = 4; int origList[NUM_VALS]; int offsetAmount[NUM_VALS]; int i;

origList[0] = 20; origList[1] = 30; origList[2] = 40; origList[3] = 50;

offsetAmount[0] = 5; offsetAmount[1] = 7; offsetAmount[2] = 3; offsetAmount[3] = 4;

/* Your solution goes here */

printf(" ");

return 0; }

2. Complete the function definition to output the hours given minutes. Output for sample program:

3.500000 

#include

void OutputMinutesAsHours(double origMinutes) {

/* Your solution goes here */

}

int main(void) {

OutputMinutesAsHours(210.0); // Will be run with 210.0, 3600.0, and 0.0. printf(" ");

return 0; }

3. Declare an array sandwichesInStore of 3 SandwichIngredients elements.

#include #include

typedef struct SandwichIngredients_struct { char sandwichName[30]; char ingredients[70]; } SandwichIngredients;

int main(void) {

/* Your solution goes here */

strcpy(sandwichesInStore[0].sandwichName, "Chicken and Bacon"); strcpy(sandwichesInStore[0].ingredients, "Crispy chicken, onions, lettuce, bacon, mayonnaise"); strcpy(sandwichesInStore[1].sandwichName, "Chicken breast"); strcpy(sandwichesInStore[1].ingredients, "Grilled chicken, lettuce, tomato"); strcpy(sandwichesInStore[2].sandwichName, "Chicken with peppers"); strcpy(sandwichesInStore[2].ingredients, "Grilled chicken, red and green peppers, barbacue sauce");

printf("%s: %s ", sandwichesInStore[0].sandwichName, sandwichesInStore[0].ingredients); printf("%s: %s ", sandwichesInStore[1].sandwichName, sandwichesInStore[1].ingredients); printf("%s: %s ", sandwichesInStore[2].sandwichName, sandwichesInStore[2].ingredients);

return 0; }

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!