a.
float a[] = {2.5, -3.3, 5.9, 1.0, 3.5, 4.3, -7.3, -3.6, 6.1, 2.6};
b.
float *p = a[2];
c.
float *q = a[8];
d.
printf("%d",*(p+3));
e.
q++;
f.
p-q = 6
g.
*q -*p = 6.1 -5.9 = 0.2
3.
void readBetween(float *p,int startIdx,int endIdx) {
fot(int i = startIdx;i<endIdx;i++)
printf("%f",*(p+i));
}
4.
void tripleOdds(double *p,int endIdx){
for(int i = 0;i<endIdx;i++)
*(p+i) = 3* *(p+i);
}
5
a.
#define STR_LEN 50
b.
string day[5][STR_LEN];
day[0][STR_LEN] = "Monday";
day[0][STR_LEN] = "Tuesday";
day[0][STR_LEN] = "Wednesday";
day[0][STR_LEN] = "Thursday";
day[0][STR_LEN] = "Friday";
Do ask if any doubt. Please upvote.
(15 pts) Using the following example, int a, p=&a; *p = 20; Give the two major...
C language 3. (10 pts) Write a function readSegment that takes three parameters, a float array as a pointer p as the first parameter, and two int indices startldx and endldx. The function readSegment reads the content of the array between startIdx and endldx, without using additional local variables. 4. (10 pts) Write a function called doubleOdds that takes two parameters, an array of double pointed to by pointer p and endldx of int type. The function doubleOdds doubles (multiply...
1. (40 pts) Consider the following function. Complete the function that does the following: (a) Take three arguments, int array, int as the length of the array, and int *max. (b) Find the maximum value and the minimum value in the array. (c) The pointer max points to the maximum value. (d) Return the pointer that points to the minimum value max)( findMinAndMax(int al l, int length, int int maxValue a[0], minValue al0 int int maxldx 0, minldx 0; for...
Using Swift playground and / or the command line for macOS (open Xcode, create a new Xcode project, macOS, command line tool), practice the following exercises: Exercise: Swift Variables Declare 2 variables/constants with some random values and any name of your choice Considering these 2 variables, one as a value of PI and other as a radius of circle, find the area of circle Print the area of circle Declare a string variable explicitly with value “Northeastern”. Declare a string...
Create 3 variables, (int, chart and float) and give give each of them some value. Print out the values. Then create a pointer for each variable and initialize the pointers. Then make them point to the memory address of the corresponding variables. Print out the pointers (=memory addresses where the pointers point to, use %p). Finally, print out the values that are in the memory locations where the pointers point to(so print out the values using the pointers, not the...
Assuming the following class declaration: class Course { private: string grade_; int units_; public: Course ( ); Course ( string grade, int units); ~Course ( ); string get_grade ( ) const ; int get_units ( ) const; }; NOTE: Class definitions are not provided but you may assume they're properly defined. Variable names used in your answers must follow our stated naming convention especially for pointer names. Write a fragment of...
using visual studio 2) For each of the following, write C++ statements that perform the specified task.. (Ref: classwork named pointer2) a) Declare a built-in array of type unsigned int called values with five elements, and initialize the elements to the even integers from 2 to 10. b) Declare a pointer vPtr that points to a variable of type unsigned int. c) Write two separate statements that assign the starting address of array values to pointer variable vPtr. d) Use...
Using C code 1. Consider a hash table that is implemented using the following struct definitions. #define NUMBUCKETS 10 typedef struct _HTE { int Key; int Value; struct _HTE *Next; } HashTableEntry; typedef struct _HT { HashTableEntry *Buckets[ NUMBUCKETS ]; unsigned int Size; } HashTable; a.) Complete the following function, which takes a pointer to a HashTableEntry, which is the head of a linked list of entries, and an integer x. It returns the first entry in the list whose...
C Programming Language 2(a) Define a struct with 1 int array named i, 1 float array named f, and one double array named d, each of size M. (b)Declare array x with N of those structs. (c)Write a void function to traverse array x (using a pointer) assigning to each element in each array d (in each struct in array x) the sum of the corresponding elements in arrays i and f (in the same struct). Use 3 pointers (of...
code in C language ADT: typedef struct{ int ID; float salary; int age; }Employee; Specification: In this lab, five functions need to be implemented using the given ADT. 1. Employee* readRecord(FILE*) This function receives a FILE pointer created before. It reads a line from the provided csv file, and creates an Employee struct pointer with the information from that line then returns the pointer back to the calling function. Each line in the provided csv file contains the id, salary,...
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...