QUESTION 1
In order to print the members of structures in the array, what will be the contents of blanks in the printf statement of the code snippet given below?
#include <stdio.h>
struct virus
{ char signature[25];
char status[20];
} v[2] = {
"Yankee Doodle", "Deadly",
"Dark Avenger", "Killer"
} ;
void main( )
{
for (int i = 0; i < 2; i++)
printf( "\n%s %s", _______________ , _____________ );
}
| A. |
signature, status |
|
| B. |
v.signature, v.status |
|
| C. |
v[i].signature, v[i].status |
|
| D. |
v.signature[i], v.status[i] |
2 points
QUESTION 2
struct time
{
int hours ;
int minutes ;
int seconds ;
} t ;
struct time *tt ;
tt = &t ;
With reference to above declarations, which of the following refers to seconds correctly:
| A. |
tt.seconds |
|
| B. |
(*tt).seconds |
|
| C. |
time.t |
|
| D. |
*tt.seconds |
2 points
QUESTION 3
What is the output of following C statements?
char *ptr = calloc(100, 1);
ptr = "Welcome";
printf("%s\n", ptr);
| A. |
Segmentation Fault |
|
| B. |
Welcome |
|
| C. |
Garbage values |
|
| D. |
Compile-time Error |
2 points
QUESTION 4
What is the output of following C program?
#include <stdio.h>
#include <stdlib.h>
struct p
{
struct p *next;
int x;
};
int main( )
{
struct p* p1 = malloc(sizeof(struct p));
p1->x = 1;
p1->next = malloc(sizeof(struct p));
printf("%d\n", p1->next->x);
return 0;
}
| A. |
1 |
|
| B. |
0 |
|
| C. |
Garbage value |
|
| D. |
Compile-time Error |
2 points
QUESTION 5
What is the output of following C code?
struct employee
{
char *emp;
};
int main( )
{
struct employee e1;
struct employee *ePtr = &e1;
(*ePtr).emp = "Hello";
printf("%d\n%d\n", ePtr, &e1);
return 0;
}
| A. |
Run-time Error |
|
| B. |
Hello Hello |
|
| C. |
Different address |
|
| D. |
Same address |
2 points
Question 1: v[i].signature, v[i].status Question 2: (*tt).seconds Question 3: Welcome Question 4: Garbage value Question 5: Same address

QUESTION 1 In order to print the members of structures in the array, what will be...
Given the struct xx with the following members: int x-3; char namell-"hello"; What would be the output of the following program? 1. void main) 2. 3. struct xx "s-malloc(sizeof(struct xx)); 4, printf("%d",s->x); 5. printf("%s",s->name); 3 hello Garbage value hello 3 Garbage Value Compiler error None of the above
OPERATING SYSTWM
Question 31 What is the output of this C program? #include #include void main() int mptr, *cptr mptr = (int*)malloc(sizeof(int)); printf("%d", "mptr); cptr = (int)calloc(sizeof(int),1); printf("%d","cptr); garbage 0 000 O garbage segmentation fault Question 8 1 pts If this program "Hello" is run from the command line as "Hello 12 3" what is the output? (char '1'is ascii value 49. char '2' is ascii value 50 char'3' is ascii value 51): #include<stdio.h> int main (int argc, char*argv[]) int...
Question 11 pts Fill in the blank. Two functions are defined main.c and MyAge.c // FILE main.c main ( ) { _______ int age ; printf ( " the value of age is %d \n", age ) ; } // FILE MyAge.c int age = 10; int MyAge ( ) { } Group of answer choices static external internal extern Flag this Question Question 21 pts Fill in the blank. Two functions are defined main.c and MyAge.c The below program...
Please explain step by step what is going on each step.please clearly explain line by line the working of code . Also provide the output. I would rate positively. Thank you so much . #include <stdio.h> #include <stdlib.h> struct node { int data; struct node *next; }; struct node *head = NULL; void printList() { struct node *ptr = head; printf("\nhead:"); while(ptr != NULL) { printf("node addr:%p \tdata:%d \tnext addr:%p\n”, ptr,ptr->data,ptr->next); ptr = ptr->next; } printf(" [null]\n"); } void insert(int data) { struct node *link = (struct node*) malloc(sizeof(struct node)); link->data = data; link->next = head; head = link; } int main() {...
QUESTION 6 What is the output of following C code? struct numbers { int x = 2; int y = 3; } int main() { struct numbers nums; nums.x = 110; nums.y = 100; printf("%d\n%d", nums.x, nums.y); return 0; } A. Compile-time Error B. 110 100 C. 2 3 D. Run-time Error 2 points QUESTION 7 What is the output of following C code? typedef struct student { char *stud; }s1; int main() { s1 s; s.stud...
Hi, I need to make a program in C that reads the type of currency and organizes them into stacks based on currency which can be read back. This is what I have so far, can I get help finishing it? #include <stdio.h> #include <stdlib.h> const float POUND = 1.31; const float YEN = 0.0091; const float RUPEE = 0.014; const float EURO = 1.11; char c; int currValue; float exchangeValue; float finValue; int printValue; struct node { int...
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...
Could someone please help me with this C language code I'm confused as to why i'm getting an error every time I run it on command line if some could please help me as soon as possible. #include <stdio.h> #include <stdlib.h> int main() { char *ptr_two = (char *)malloc(sizeof(char)*50); printf("%p\n", ptr_two); ptr_two = "A constant string in C"; printf("%p\n", ptr_two); printf("%s\n", ptr_two); free(ptr_two); return 0; }
please help me with this question
(in C programming language and Unix)
computer system book 3 edition
int *fun (int *x)f int value *xtt return &value; int main) int pl; int **p2; int a; char str [5] printf ("Enter a number:") scanf("%d", a) ; printf ("Enter a line:") gets (str); p1-malloc(sizeof (int)) *pl-p2; p2-malloc(sizeof (int)); pl-fun (a); n-0; for (pl-stripl<-str+5;pl++) if (isdigit (pl)) at+; return 0; Construct a table that shows for each line of code, what may be the...
Q.25. Given the following program, you are asked to discuss memory leaks caused in its execution. Determine which memory locations get uncontrolled. (2 points) 4 6 7 8 9 10 11 12 B 13 14 15 16 17 18 1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <string.h> 5 void main() { char *aString = "Memory leaks?"; char **strList; int i, n = 5; strlist = (char**)malloc(n*sizeof(char*)); for (i=0; i<n; i++) { printf("\nstring %d ", i+1); strList[i] = (char*)malloc(50*sizeof (char));...