If you post more than 1 question, as per HomeworkLib guideline I have to solve only 1 question.
Ques 2. Answer : (b) a template function
In a template, we define a generic function in which the data tye is variable. It can be of any type like int, float, string etc.
Ques 3. Garbage collection
It is the property by which unused memory is given back to the OS.
1.What will be output if you will compile and execute the following c code? struct markst...
Codelab question! This is c++. Consider the following code: // Linked Lists: TRAVERSE struct ListNode { int data; struct ListNode *next; }; Assume that a linked list has been created and head points to a sentinel node. A sentinel node is an empty data node in the beginning of the list. It sometimes holds a sentinel value. The use of sentinel nodes is a popular trick to simplify the insert and delete operations. You may also assume that the list...
C programming The program will require the following structure: struct _data { char *name; long number; }; The program will require command line arguments: int main(int argv, char **argc) { Where argv is the number of arguments and argc is an array holding the arguments (each is a string). Your program must catch any case where no command line arguement was provided and print a warning message (see below). You MUST include/use the following functions, defined as follows: int SCAN(FILE...
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct game_piece
{
};
struct game_board
{
};
void game_piece_init_default(struct game_piece* piece)
{
}
void game_piece_init(struct game_piece* piece, char*
new_label)
{
}
char* game_piece_get_label(struct game_piece* piece)
{
return "";
}
char* game_piece_to_string(struct game_piece* piece)
{
return "";
}
void game_board_init(struct game_board* game_board, int rows,
int cols)
{
}
int game_board_is_space_valid(struct game_board* game_board, int
row, int
col)
{
return 0;
}
int game_board_add_piece(struct game_board* game_board, struct
game_piece*
piece, int row, int col)
{
return 0;...
Modify the below code to fit the above requirements:
struct node
{
char data;
struct node *next;
struct node *previous;
} *front, *MyNode, *rear, *MyPointer, *anchor *Valuenode ;
typedef struct node node;
int Push(char input)
{
if(IsFull()==1)
{
printf("The queue is full. Enter the ‘^’ character to
stop.\n");
return -1;
}
else if (IsFull()==-1)
{
node *MyNode=(node*)malloc(sizeof(node));
MyNode->data=input;
rear->next=MyNode;
MyNode->previous=rear;
MyPointer=rear=MyNode;
return 1;
}
else
{
node *MyNode=(node*)malloc(sizeof(node));
node *anchor=(node*)malloc(sizeof(node));
MyNode->data=input;
MyPointer=rear=front=MyNode;
MyNode->previous=NULL;
MyNode->next=NULL;
anchor->next=MyNode;
return 0;
}
}
char...
1. What is the output? System.out.print(3 + 3 * 3); a. 18 b. 12 c. 9 d. 0 e. 10 2. What is output by the code below? System.out.print("\\dog\\cat"); a. dog b. dogcat c. \\dog\\cat d. \dog\cat e. catdog\\\\ 3. What is returned by the call getIt(9) ? public static int getIt(int num){ int ans = 0; if( num >=2 ) { if( num >= 7) ans += 2; else ans += 3; } ans += 4; return ans; }...
Need this in C
The starter code is long, if you know how to do it in other way
please do.
Do the best you can please.
Here's
the starter code:
//
-----------------------------------------------------------------------
// monsterdb.c
//
-----------------------------------------------------------------------
#include
#include
#include
//
-----------------------------------------------------------------------
// Some defines
#define NAME_MAX 64
#define BUFFER_MAX 256
//
-----------------------------------------------------------------------
// Structs
typedef struct
{
char name[NAME_MAX];
int hp;
int attackPower;
int armor;
} Character;
typedef struct
{
int size;
Character *list;
} CharacterContainer;
//
-----------------------------------------------------------------------
//...
write C code that uses pointers, arrays, and C strings. 3. Write a function called pow_xy. The function should be passed 2 parameters, as illustrated in the prototype below. int pow_xy(int *xptr, int y); Assuming that xptr contains the address of variable x, pow_xy should compute x to the y power, and store the result as the new value of x. The function should also return the result. Do not use the built-in C function pow. For the remaining problems,...
1. What is output by the following code: ArrayList< Integer > a = new ArrayList< Integer >(); ArrayList b = a; a.add(new Integer(4)); b.add(new Integer(5)); a.add(new Integer(6)); a.add(new Integer(7)); System.out.println(b.size()); A)1 B)2 C)3 D)4 E)5 2. Assume the Student and Employee classes each extend the Person class. The Student class overrides the getMoney method in the Person class. Consider the following code: Person p1, p2, p3; int m1, m2, m3; p1 = new Person(); m1 = p1.getMoney(); // assignment 1...
Using C Please comment
Part 1: BST Create a link based Binary Search tree composed of a Node and a Tree struct. You should have a header file, BST.h, with the following: o Node struct containing left, right, and parent pointers, in addition to holding an Data struct value Tree struct containing a pointer to the root of the tree A function declaration for a function that allocates a tree, and initializes the root to NULL o o o A...
1) Create a struct called CourseInfo to store info about a course (Include variables for courseNum, courseName, & grade) 2) Change the type for the 'data' member variable in the node struct to CourseInfo (see #1) and rename it to 'courseData' 3) Modify the createNode function to receive a CourseInfo struct as a parameter. It should also display the address of the new node that is created. Display the address in both hex and decimal form. 4) Modify the display...