Fill in the missing C code according to the comments.
#include <stdio.h>
typedef struct {
int num;
char name[25];
} student;
int main(){
student s1;
//assign the value of 1234 to num in
the s1 structure
//assign the value of Bob the Builder
to name in s1 structure
//display the value of num in the s1 structure
//display the value of name is the s1 structure
student *s2;
//assign the value of 7754 to num in
the s2 structure
//assign the value of Bullwinkle to
name in s2 structure
//display the value of num in the s2 structure
//display the value of name is the s2 structure
return 0;
}//end main()
#include <stdio.h> #include <string.h> #include <stdlib.h> typedef struct { int num; char name[25]; } student; int main(){ student s1; //assign the value of 1234 to num in the s1 structure s1.num = 1234; //assign the value of Bob the Builder to name in s1 structure strcpy(s1.name, "Bob the Builder"); //display the value of num in the s1 structure printf("%d\n",s1.num); //display the value of name is the s1 structure printf("%s\n",s1.name); student *s2 = (student*)malloc(sizeof(student)); //assign the value of 7754 to num in the s2 structure s2->num = 7754; //assign the value of Bullwinkle to name in s2 structure strcpy(s2->name, "Bullwinkle"); //display the value of num in the s2 structure printf("%d\n",s2->num); //display the value of name is the s2 structure printf("%s\n",s2->name); return 0; }//end main()
Fill in the missing C code according to the comments. #include <stdio.h> typedef struct { ...
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...
Canvas → XC D Question 13 Given the code below: typedef struct p { char topic [20]; int nunWords; > page; typedef struct mag char name[20]; page pages [250); int numPages; } magazine; magazine m; How would you declare an array of 20 magazines? struct magazine[20] magazine[20] magazine myStack(20) None of the above struct m[191 Question 14 Given the code below: typedef struct char topic[20] Canvas & XC struct m[19] Question 14 Given the code below: typedef struct char topic[20];...
Complete the program below in C please #include <stdio.h> #inlcude <stdlib.h> #include <time.h> typedef struct { int points; int strength; } Hero; /* print out the hero given by the parameter */ void printHero( ... ) { . . } void main() { Hero heroA, heroB; /* initialize both heroes to your choice of values */ . /* Pick one hero using rand(). Print out that hero */ . }
Given the following program: #include <stdio.h> struct student { int id; char name[20]; char grade; }; void func(struct student stud); int main() { struct student astud; astud.id=9401; strcpy(astud.name, "Joe"); astud.grade = 'A'; func(astud); return 0; } Abdelghani Bellaachia, CSCI 1121 Page: 16 void func(struct student astud) { printf(" Id is: %d \n", astud.id); printf(" Name is: %s \n", astud.name); printf(" Grade is: %c \n", astud.grade); } Modify this program to include the address of a student as a separate structure....
Please complete the c++ code. The code that needs completing is outlined in the comments. #include <stdio.h> #include<stdlib.h> #include<math.h> struct student{ int id; int score;}; struct student* allocate(){ /*Allocate memory for ten students*/ /*return the pointer*/ } void generate(struct student* students){ /*Generate random and unique ID and scores for ten students, ID being between 1 and 10, scores between 0 and 100*/ } void output(struct student* students){ /*Output information about the ten students in the format: ID1 Score1 ID2 score2...
I NEED HELP FINDING THE BUG IN THIS CODE USING THE GDB #include #include <stdio.h> <string.h> Return the result of appending the characters in s2 to s1 Assumption: enough space has been allocated for sl to store the extra characters. char* append (char s1[ ], char s2[ ]) int sllenstrlen (s1); int s2lenstrlen (s2) int k; for (k=0; k<s21en; k++) { sl [kts11en] = s2 [k] ; return sl; int main () char strl [10]; char str2 [10]; while (1)...
The following C code defines a structure for student and then creates a student structure type variable by setting the no as 8 and name as "Demo". One statement is missing in this C code. Please select one statement from the following options to make this program work. s ions s saved Status include <stdio.h> include <string. h struct student int no; char name void main struct student s; S. no 8 print f("Ed 8s In", s. no, s. name)...
C PROGRAMMING #include <stdio.h> #include <stdlib.h> struct nodet { int data; struct nodet *link; }; struct nodet *makeAnode(int val) { struct nodet *box; box = malloc(sizeof(struct nodet) ); box->data = val; box->link = NULL; return box; } void printList(struct nodet *L) { struct nodet = *mov; mov = L; while(mov != NULL) { printf("%d ", mov->data); mov = mov->link; } printf("\n"); } // THIS SHOULD COUNT HOW MANY ITEMS (NODES) ARE IN THE LIST. int listLen(struct nodet **L) { int...
Would u help me fixing this CODE With Debugging Code with GDB #include <stdio.h> #include <stdlib.h> #define SIZE (10) typedef struct _debugLab { int i; char c; } debugLab; // Prototypes void PrintUsage(char *); void DebugOption1(void); void DebugOption2(void); int main(int argc, char **argv) { int option = 0; if (argc == 1) { PrintUsage(argv[0]); exit(0); } option = atoi(argv[1]); if (option == 1) { DebugOption1(); } else if (option == 2) { DebugOption2(); } else { PrintUsage(argv[0]); exit(0); } }...
C program help 2. For the following code: #include "stdafx.h" struct State char out struct State *next[2]; b; typedef struct State States; #define STe &FSM[8] #define ST1 &FSM[1] #define ST2 &FSM[2] States FSM[3] { {"L', {STe, ST1)), {'1', {STe, sT2)), {ST1, = {.2', ST2))); int main() States "ptr &FSM[e]; int in; while (1) printf("cIn", ptr->out); printf("Enter a e or 1 to operate this machine: "); scanf s("Xd", &in); ptr ptr->next[in]; return e; Draw the finite state machine diagram for this...