1.
struct Rectangle{
float width;
float height;
float topleft_x;
float topleft_y;
};
struct Rectangle rect;
2.
size of var1 = 9 bytes
size of var2 = 20 bytes (Union takes up the size of the biggest
element)
3.
a.enum Boolean IsEquilateral(struct Trianle *triangle){
if (triangle->side1 == triangle->side2
&& triangle->side2 == triangle->side3){
return TRUE;
}
else {
return FALSE;
}
}
b. t1.side1 = 5.0;
t1.side2 = 5.0
t1.side3 = 5.0
c.
declare a variable of type enum Boolean as
follows:
enum {TRUE, FALSE} result;
result = IsEquilateral(&t1);
d. t2 = t1;
4.
The output is 84
5.
struct Record std2;
std2.name = "Jennifer";
printf("%s", std2.name);
struct Record *rec;
rec = &std2;
rec->grade1 = 76;
(*rec).grade2 = 86;
scanf("%d", &(*rec).grade2);
C language not C++ 1. Write the statements to do the following: (2 pts) a. Define...
C programming. (30 pts) Consider the following code. struct Triangle { float side1; float side2; float side3;} t1, t2; enum Boolean {FALSE, TRUE}; enum Boolean isEquilateral(struct Triangle * triangle); a. (15 pts) Implement the function isEquilateral which returns enum value TRUE if the given triangle is equilateral and enum value FALSE otherwise. (Hint: in the real world, no two float values are exactly the same. If the difference of two float values is between -0.0001 and 0.0001, consider “almostEqual” and...
State true or false: (6 x 2 = 12 pts) Using -- with a reverse iterator moves it from the back toward the front of a list b) The body of a do-while loop is always executed at least once. c) If p points to the array element a[j], then p + i points to a[i+j]. d) Any number of pointer variables may point to the same object. In terms of both execution speed and memory usage usually iterative solutions...
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...
C++ Question 1) Consider a class Point that models a 2-D point with x and y coordinates. Define the class point that should have the following Private data members x and y (of type int), with default values of 0 A constant ID of type int A private static integer data member named numOfPoints This data member should be o Incremented whenever a new point object is created. o Decremented whenever a point object is destructed. A default constructor An...
in C language we need to find the following : EXERCISE 3: 1. Write the definition of a structure named employee that contains character array members for an employee's first and last names, an int member for the employee's age, a char member that contains 'M' or 'F' for the employee's gender, and a double member for the employee's hourly salary. 2. Using the above mentioned definition, write a C program that asks a user to enter the values of...
Question 1: Pointers You are given the following C code and memory diagram. The “contents” column of the memory diagram shows the value of the variable. Update the “contents” column of the memory diagram for each assignment in main(). long *pt; long data; long buffer[4]; void main(void){ pt = &buffer[1]; *pt = 1234; data = *pt; } address contents variable 0x20000000 0x00000000 pt 0x20000004 0x00000000 data 0x20000008 0x00000000 buffer[0] 0x2000000C 0x00000000 buffer[1] 0x20000010 0x00000000 buffer[2] 0x20000014 0x00000000 buffer[3]...
Hi, I hope I can get some help with the following exercise in C++( CPP): 1.Write an additional method called push_back(int) that will add an integer to the end of the list. You can modify the provided code. 2.Modify the Node class and LinkedList class so that you can access your parent node (double linked-list). #include #include using namespace std; typedef int Type; enum Boolean { False = 0, True }; class Item { friend class SLList; public: Type getVal()...
Hello, please solve this problem for object oriented programming in C++ program language. I have final tomorrow so it will be very helpful. thank you. PROBLEM 1: application that simulates the highway Create an In order to solve above mentioned requirements, it is necessary to implement several classes: 1. Class Vehicle contains information about the vehicles that drive on the highway. Each vehicle has information about its a Type (can be one of these: Motorcycle, Car, Truck) b. License number...
Write a program that supports the three phases (setup, voting and result-tallying) which sets up and executes a voting procedure as described above. In more details: You can start with the given skeleton (lab6_skeleton.cpp). There are two structures: Participant structure, which has the following members: id -- an integer variable storing a unique id of the participant (either a candidate or a voter). name -- a Cstring for storing the name of the participant.. hasVoted -- a boolean variable for...