Suppose we have three variables declared as
char *pc;
int *pi;
struct point {double x; double y;};
struct point *p1;
struct point *p2[10];
Assume sizeof(char)=1, sizeof(int)=4, sizeof(double)=8.
The values of pc, pi, p1 and p2 are 240, 258, 410 and 480 respectively. What are the values of pc+1, pi+2, p1+4 and p2+3
Suppose we have three variables declared as char *pc; int *pi; struct point {double x; double...
3. (8 pts) You need to understand how to define and use a struct for this exercise. You should be able to figure out the answer without actually compiling or running the program. Which is true about the following codes? If you choose a, you need to specify where the syntax error(s) occur; if you choose b, you need to specify what error occurs when you run it; if you choose c, you need to specify the outputs of the...
#include <stdio.h> int main(int argc, char *argv[]) { char a, *pc, c[9]; int i, *pk, k[9]; a='z'; pc=&(c[8]); pk=&(k[0]); for (i=0; i<9; i++) { *pc=a-(char)i; pc--; *pk=(int)a-i; pk++; } return 0; }//end of main Answer the below questions with the above code Write out the memory map for the above C code in the following table. For array variables, list the address range for the entire array. Assume the memory address starts from 100, that is, the address for a...
using c++
Write a C++ program which reads three values of types char, int, double and string from the keyboard and primis, appropriately formatted, assigned values and variable types. For example, if letter, number, and real are variables of type char, int and double respectively, and if the values assigned to them using cin function are: a, 1, and 3.1415, then the output should be: a is a character 1 is an integen 3.1415 is a real number
QUESTION 6 What is the output of following C code? struct numbers { int x = 2; int y = 3; } int main() { struct numbers nums; nums.x = 110; nums.y = 100; printf("%d\n%d", nums.x, nums.y); return 0; } A. Compile-time Error B. 110 100 C. 2 3 D. Run-time Error 2 points QUESTION 7 What is the output of following C code? typedef struct student { char *stud; }s1; int main() { s1 s; s.stud...
Cache performance The starting code would have: struct position { int x; int y; } int N; struct position grid[N][N]; int totalX=0; int totalY=0; int i, j; //For X loop for( i = 0; i < N; i ++){ for( j = 0; j < N; j++){ totalX += grid[i][j].x; } } //For Y loop for( j = 0; j < N; j++){ for( i = 0; i < N; i++){ totalY += grid[i][j].y; } } Part I: This part...
Homework Part 1 Write a C program that declares and initializes a double, an int, and a char. You can initialize the variables to any legal value of your choosing. Next, declare and initialize a pointer variable to each of the variables Using printf), output the following: The address of each of the first three variables. Use the "Ox%x" format specifier to print the addresses in hexadecimal notation The value of each variable. They should equal the value you gave...
Three variables x, y, and z defined as unsigned char, short, and int types in C Programming. What are the maximum values they can take? Compare the following C programs. After execution of this short programs what will be the value of x if printed in function? void foo(void); int main(void){ foo(); foo(); foo(); return 0; } void foo() { int x = 1; x++; } void foo(void); int main(void){ foo(); foo();...
Declare the following three variables: char letter; int number; double decimalNumber; Prompt the user to enter a letter. Read the letter into the variable letter Assign to the variable number the value from the variable letter Assign to the variable decimalNumber the value from the variable number Print the values of the three variables using the following format: Character: K Number: 75 Decimal number: 75 Test the program with the input letter a and copy the results into a comment...
Suppose x, y, and z are int variables and w and t are double variables. What value is assigned to each of these variables after the last statement executes? a) x = 17; b) y = 15; c) x = x + y / 4; d) z = x % 3 + 4; e) w = 17 / 3 + 6.5; f) t = x / 4.0 + 15 % 4 - 3.5;
Suppose we have a struct type IntPair with members int smaller and int bigger. Implement the function IntPair getSmallestAndBiggest(int nums[], int length); that returns an IntPair with the smallest value of nums in member smaller and the biggest value of nums in the member bigger. Note: If length is 1 and more generally if all the elements of nums have the same value then smaller and bigger will be equal. (You may assume that length ≥ 1.)