Question

QUESTION 1 In order to print the members of structures in the array, what will be...

QUESTION 1

  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

  1.   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

  1. 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

  1. 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

  1. 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   

0 0
Add a comment Improve this question Transcribed image text
Answer #1
Question 1:
v[i].signature, v[i].status

Question 2:
(*tt).seconds

Question 3:
Welcome

Question 4:
Garbage value

Question 5:
Same address

Please up vote the solution if it helped. Thanks!

Add a comment
Know the answer?
Add Answer to:
QUESTION 1 In order to print the members of structures in the array, what will be...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Given the struct xx with the following members: int x-3; char namell-"hello"; What would be the...

    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()...

    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...

    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...

  • Hi, I need to make a program in C that reads the type of currency and...

    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...

    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...

    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 edi...

    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...

  • I need to make it so this program outputs to an output.txt, the program works fine,...

    I need to make it so this program outputs to an output.txt, the program works fine, just need it to fprintf to output.txt #include <stdio.h> #include <string.h> #include <malloc.h> #define MAX 30 struct treeNode { char names[MAX];    struct treeNode *right; struct treeNode *left; }*node; void searchName(char names[], struct treeNode ** parent, struct treeNode ** location) { struct treeNode * ptr, * tempPtr; if(node == NULL)    { *location = NULL; *parent = NULL; return; } if(strcmp(names, node->names) == 0)...

  • Question 1 Consider the following program fragment that defines a self-referential class: #include <stdlib.h> #include <stdio.h>...

    Question 1 Consider the following program fragment that defines a self-referential class: #include <stdlib.h> #include <stdio.h> struct node_int; typedef struct node int *node; struct node_int void *data; node next; typedef struct list_int (node first;} *list; void main(int argc, char *argv[]) list shopping, t; node n; int x=25; shopping=(list) malloc(sizeof(struct list_int)); n= (node) malloc(sizeof(struct node_int)); n->data=shopping; n->next=NULL; shopping->first=n; t=(list) (shopping->first->data); // ***** t->first=NULL; // ***** n->data=&x; printf("%d\n", *((int *) (shopping->first->data))); a What will be displayed on the screen if the above...

  • Q.25. Given the following program, you are asked to discuss memory leaks caused in its execution....

    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));...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT