Write a statement that calls a function named IncreaseItemQty, passing the variable addStock. Assign notebookInfo with the value returned by IncreaseItemQty.
#include <stdio.h>
#include <string.h>
typedef struct ProductInfo_struct {
char itemName[30];
int itemQty;
} ProductInfo;
ProductInfo IncreaseItemQty (ProductInfo productToStock, int
increaseValue) {
productToStock.itemQty = productToStock.itemQty +
increaseValue;
return productToStock;
}
int main(void) {
ProductInfo notebookInfo;
int addStock = 10;
scanf("%s", notebookInfo.itemName);
scanf("%d", ¬ebookInfo.itemQty);
/* Your solution goes here */
printf("Name: %s, stock: %d\n", notebookInfo.itemName, notebookInfo.itemQty);
return 0;
}
#include <stdio.h>
#include <string.h>
typedef struct ProductInfo_struct {
char itemName[30];
int itemQty;
} ProductInfo;
ProductInfo IncreaseItemQty (ProductInfo productToStock, int
increaseValue) {
productToStock.itemQty = productToStock.itemQty +
increaseValue;
return productToStock;
}
int main(void) {
ProductInfo notebookInfo;
int addStock = 10;
scanf("%s", notebookInfo.itemName);
scanf("%d", ¬ebookInfo.itemQty);
/* Your solution goes here */
notebookInfo=IncreaseItemQty(notebookInfo,
addStock);
printf("Name: %s, stock: %d\n", notebookInfo.itemName,
notebookInfo.itemQty);
return 0;
}
Output:
Name: aaaaaaaaaa, stock: 15
Write a statement that calls a function named IncreaseItemQty, passing the variable addStock. Assign notebookInfo with...
Write a statement that calls a function named IncreaseltemQty, passing the variable addQty. Assign notebooklnfo with the value returned by IncreaseltemQty 9 ProductInfo IncreaseItemQty (ProductInfo productToStock, int increaseValue) productToStock.itenQty = productToStock. ItemQty + increaseValue; 12 return productToStock 14 15 int main(void) ProductInfo notebookInfo int addQty; 16 17 19 addQty 1e; 20 21 scanf("%s", scanf("%d.. , notebookInfo . ItemName); ¬ebookInfo.itemQty); 22 24 productInfo-IncreaseItemQty (productInfo, addstock) Your solution goes here/ 25 26 printf("Name : %s, stock: %d\n", notebookInfo.itemName, notebookInfo.itenQty); 27 return ;...
CHALLENGE ACTIVITY 5.71 String library functions. Assign the size of userinput to stringSize. Ex: if userinput is 'Hello output is: Size of user Input: 5 1 #include <stdio.h> 2 #include <string.h> 4 int main(void) { char user Input[50]; int stringSize; BO scanf("%s", userInput); /* Your solution goes here" printf("Size of user Input: %d\n", stringsize); return ; Run
PLease explain output of these two programs: 1. #include <stdio.h> typedef struct { char *name; int x, y; int h, w; } box; typedef struct { unsigned int baud : 5; unsigned int div2 : 1; unsigned int use_external_clock : 1; } flags; int main(int argc, char** argv){ printf("The size of box is %d bytes\n", sizeof(box)); printf("The size of flags is %d bytes\n", sizeof(flags)); return 0; } 2. #include <stdio.h> #include <string.h> /* define simple structure */ struct { unsigned...
In C Set hasDigit to true if the 3-character passCode contains a digit. 1 #include «stdio.h> 2 #include«string.h> 3 #include «stdbool.h 4 #include<ctype.h> 6 int main(void) 7 bool hasDigit; 8 char passCode501; 10 11 12 hasDigit false; scanf("%s", &passcode); 13 Your solution goes here * 14 15 if (hasDigit) 16 printf("Has a digit.n 4 #include <ctype.h> 6 int main (void) 1 8 char passCode [50]; bool hasDigit; hasDigit- false; 10 11 scanf("%s",&passcode); 12 13 14 15 if (hasDigit) 16 17...
1. Write a statement that calls a function named showSquare, passing the value 10 as an argument. 2. Write the function prototype for a function called showSquare. The function should have a single parameter variable of the int data type and areturn type of void. 3. Write the function prototype for a function called showScoreswith a parameter list containing four integer variables and a return type of void. 4. Look at the following function definition: double getGrossPay(int hoursWorked, double payRate)...
coding in C Programming Assign the size of userInput to stringSize. Ex: if userInput = "Hello", output is: Size of userInput: 5 #include < stdio.h > #include < string.h > int main(void) { char userlnput[50] = "": int stringSize = 0: strcpy(userInput, "Hello"): /* Your solution goes here */ printf("Size of userlnput: %d\n", stringSize): return 0: }
Q 1. Q 2. if it works, I'll thumb up for u. Complete the function createStudent below: #include <stdio.h> #include <stdlib.h> struct student { char name[50]; int age; struct student *next; }; struct student * createStudent(char studentName[], int studentAge) { } int main() { struct student *studptr; int myAge; char myName[50]; scanf("%s %d", myName, &myAge); studptr = createStudent(myName, myAge); printf("Student %s is %d years old.\n", studptr->name, studptr->age); free(studptr); return 0; } For example: Test Input Result Zhangwei Student Zhangwei is...
"Simon Says" is a memory game where "Simon" outputs a sequence of 10 characters (R, G, B, Y) and the user must repeat the sequence. Create a for loop that compares the two strings starting from index 0. For each match, add one point to userScore. Upon a mismatch, exit the loop using a break statement. Assume simonPattern and userPattern are always the same length. Ex: The following patterns yield a userScore of 4: simonPattern: RRGBRYYBGY userPattern: RRGBBRYBGY #include <stdio.h>...
In C please Write a function so that the main() code below can be replaced by the simpler code that calls function MphAndMinutesToMiles(). Original maino: int main(void) { double milesPerHour, double minutes Traveled; double hours Traveled; double miles Traveled; scanf("%f", &milesPerHour); scanf("%lf", &minutes Traveled); hours Traveled = minutes Traveled / 60.0; miles Traveled = hours Traveled * milesPerHour; printf("Miles: %1f\n", miles Traveled); return 0; 1 #include <stdio.h> 3/* Your solution goes here */ 1 test passed 4 All tests passed...
Combine two codes (code 1) to get names with(code 2) to get info: Code 1: #include<unistd.h> #include<sys/types.h> #include<sys/stat.h> #include<fcntl.h> #include<dirent.h> #include<stdio.h> #include<stdlib.h> void do_ls(char []); int main(int argc,char *argv[]) { if(argc == 1) do_ls("."); else while(--argc){ printf("%s:\n",*++argv); do_ls(*argv); } } void do_ls(char dirname[]) { DIR *dir_ptr; struct dirent *direntp; if((dir_ptr = opendir(dirname)) == NULL) fprintf(stderr,"ls1:cannot open %s\n",dirname); else { while((direntp = readdir(dir_ptr)) != NULL) printf("%s\n",direntp->d_name); closedir(dir_ptr); } } ____________________________ code 2: #include <stdio.h> #include <sys/types.h> #include <sys/stat.h> void show_stat_info(char *,...