Question

Given the following source programs, write down the letter that correspond to the right answer #include <stdio.h> #ifndef MEM

0 0
Add a comment Improve this question Transcribed image text
Answer #1

How does the preprocessor expand MEM(SIZE, char)?

Answer) Option: A

(char*) malloc( 10*sizeof(char));

Explanation: In the myhead.h header file SIZE is defined as 10 and also in the same header file MEM macro is defined and this MEM(size,type) macro is used in text.c file

how does the preprocessor expand SHOW(text)?

Answer) Option: G

printf("Output: %s\n",x)

Explanation: In the myhead.h header file SHOW(x) is defined and it is used in the text.c file

What is the output of SHOW(text)?

Answer) Option: C

BR151

Explanation: In the myhead.h header file MSG macro is defined as "CS262" and COPY_TEXT(dest,source) macro is defined as strcpy() function of string library. So in text.c file with the use of COPY_TEXT(text,MSG) the string in MSG i.e "CS262" is copied into 'text' and then this 'text' is passed to newtext() function which decreases the ASCII value of each character of 'text' by 1. So the value in 'text' now is BR151 and SHOW(text) will display the value BR151.

Add a comment
Know the answer?
Add Answer to:
Given the following source programs, write down the letter that correspond to the right answer #include...
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
  • 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...

  • ​what is the output? Consider the following program: #include <stdio.h> #include <stdlib.h> #define size 3 void...

    ​what is the output? Consider the following program: #include <stdio.h> #include <stdlib.h> #define size 3 void func(int **a) {int tmp; for (int i = 0; i < size; i++) {for (int j = i; j < size, j++) {tmp = *(*(a+i)+j); *(*(a+i)+j) = *(*(a+j)+i); *(*(a+j)+i) = tmp;}}} int main() {int **arr = malloc(sizeof(int*) * size); for(int i = 0; i < size; i++) {arr[i] = malloc(sizeof(int) * size); for (int j = 0; j < size, j++) arr[i][j] = 2*i...

  • Please answer problem #5 thank you str.c #include "str.h" #include <stdio.h> int str_len(...

    Please answer problem #5 thank you str.c #include "str.h" #include <stdio.h> int str_len(char *s) {    /* this is here so code compiles */ return 0; } /* array version */ /* concantenate t to the end of s; s must be big enough */ void str_cat(char s[], char t[]) {    int i, j;    i = j = 0;    while (s[i] != '\0')    /* find end of s */        i++;    while ((s[i++] = t[j++]) != '\0') /* copy t */        ;...

  • Write C programs named mystring.h and mystring.c, containing the headers and implementations of the following functions....

    Write C programs named mystring.h and mystring.c, containing the headers and implementations of the following functions. int letter_count(char *s) computes and returns the number of English letters in string s. int word_count(char *s) computes and returns the number of words in string s. void lower_case(char *s) changes upper case to lower case of string s. void trim(char *s) removes the unnecessary empty spaces of string s. mystring.h #include <stdio.h> int letter_count(char *); void lower_case(char *); int word_count(char *); void trim(char...

  • Modify the programs so that each program can both receive and send messages alternatively. Note that when you run the two programs, you should run them in two different windows ( terminals). Y...

    Modify the programs so that each program can both receive and send messages alternatively. Note that when you run the two programs, you should run them in two different windows ( terminals). You should be able to send messages from one to the other and terminate them by entering "end" //msgl.cpp / Here's the receiver program. / #include #include #include #1nclude #include <stdlib.h> <stdio.h> <string.h> <errno.h> <unistd.h> #include <sys/types.h> #include <sys/ipc.h> Winclude <sys/msg.h> struct my msg st f long int...

  • How can I integrate these programs into this menu template: #define _CRT_SECURE_NO_WARNINGS #include #include #include #include...

    How can I integrate these programs into this menu template: #define _CRT_SECURE_NO_WARNINGS #include #include #include #include #include void program_one (); void program_two (); void program_three (); void program_four(); void program_five(); int main() { int menu_option = 0; while (menu_option != 9) { printf(" = 1\n"); //Change this to your first program name. Nothing else. printf(" = 2\n"); //Change this to your second program name. Nothing else. printf(" = 3\n"); //Change this to your third program name. Nothing else. printf(" =...

  • Deleting multiples of a given integer from a linked list: #include <stdio.h> #include <stdlib.h> #include <assert.h>...

    Deleting multiples of a given integer from a linked list: #include <stdio.h> #include <stdlib.h> #include <assert.h> #define MAX 10000 typedef struct node_tag { int v; // data struct node_tag * next; // A pointer to this type of struct } node; // Define a type. Easier to use. node * create_node(int v) { node * p = malloc(sizeof(node)); // Allocate memory assert(p != NULL); // you can be nicer // Set the value in the node. p->v = v; p->next...

  • Writing a program in C please help!! My file worked fine before but when I put...

    Writing a program in C please help!! My file worked fine before but when I put the functions in their own files and made a header file the diplayadj() funtion no longer works properly. It will only print the vertices instead of both the vertices and the adjacent like below. example input form commnd line file: A B B C E X C D A C The directed edges in this example are: A can go to both B and...

  • C Programming Take screenshot of compiled output once complete. (which should look similar to the sample...

    C Programming Take screenshot of compiled output once complete. (which should look similar to the sample one provided). Will rate positively. Problem: (1) Add PopTailSLL() as a new member function to the SLL abstract data type. “Unlink” the logically-last node (tail) from the list *sll, call the DestructElement function to destruct the object pointed-to by the node’s element data member, free() the node, and decrement size. A SLL_UNDERFLOW exception occurs when size = 0. void PopTailSLL(SLL *sll); Hint PopTailSLL() is...

  • Can you help with this C programming question. I have provided the skeleton code below along...

    Can you help with this C programming question. I have provided the skeleton code below along with the Stack/Data/Process Class for you to see/reference. Along with the Stack/Data type definition.   **SKELTON CODE** #include #include #include Stack* concat_stack(Stack *s1, Stack *s2) { //your code here return NULL; } **STACK CLASS FOR YOU TO REFERENCE** #include #include #include #include Stack* create_stack(int stack_capacity) { Stack *s = (Stack*) malloc(sizeof(Stack)); if (stack_capacity < 1) { fprintf(stderr, "Error(create_stack): invalid capacity, set to 10\n"); s->capacity =...

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