4. Consider the following declarations ;
char c = ‘a’;
byte b = 1;
short s = 2;
int i = 3; long l = 4;
float f = 5.0f;
double d = 6.0;
Indicate the value which is assigned to the LHS of the assignment statement in each of the following.
a. i = b + 2 * s / 2 + i;
b. i = (b + 2 * s) / (2 + i);
c. i += (b + 2 * s) / 2 + i;
d. i += (b + 2 * s) / 2.0 + i;
e. c = (char)(c + 1);
f. i += b++ + ++i;
g. i = ++b * s++;
h. i = – – i + i – –;
a. i = b + 2 * s / 2 + i; i = 6 b. i = (b + 2 * s) / (2 + i); i = 0 c. i += (b + 2 * s) / 2 + i; i = 2 d. i += (b + 2 * s) / 2.0 + i; i = 6 e. c = (char)(c + 1); c = b f. i += b++ + ++i; i = 14 g. i = ++b * s++; i = 6 h. i = – – i + i – –; i = 10
4. Consider the following declarations ; char c = ‘a’; byte b = 1; short s...
2. Give the minimum size of each of the following C++ types, assuming that char values occupy one byte, short values occupy two bytes, int and float values occupy four bytes, double and long values occupy eight bytes, and pointers occupy four bytes. a) union u type ( double a[3]; int *b; char c[10] b) struct s1type float *d [2]; long e[4] char f[6] short *gi c) struct s2 type ( s1_type s; u type u [2]; int *h[3]; short...
Give the minimum size of each of the following C data structures, assuming that char values occupy byte, int and float values occupy four bytes, double values occupy eight bytes, and pointers occupy bytes. (a) char str[] = "Curly": (b) double *a[4][4]: (c) char *str[3] = {"Moe", "Larry", "Curly"}: (Include the space occupied by the string literals in your answer.) (d) union { int a: char b: float c[4]: }u: (e) struct { int a: char b: float c[4]: }s:...
In the code fragment below, what are the legal data types for the variable "answer"? (Multiple answers : Choose all that apply ) byte b = 1; char c = 2; short s = 3; int i = 4 ; float f = 5f; answer = b * c * s * i * f; a. byte b. char c. short d. int e. float f. double g. long
1 Rewrite the following program so that it will use function. include <stdio.h> Int main) printf ("Hello!") return 0 2 Assume a program has the following declarations: short s- 4 int i--5; long m-3 float f-19.3f; double d-3.6; What are the following values? (a) s+m (b) (float) d (c) d s (e) (int) f 3 What will be the output of the following program: int x = 3 float a 2.76; y-2* x; print f("X-2d, y*ta, z»%d", x, y, z);...
Programing C Create union integer with members char c, short s, int i and long l. Write a program that inputs values of type char, short, int and long and stores the values in union variables of type union integer. Each union variable should be printed as a char, a short, an int and a long. Make sure that the correct values are printed as shown below in the example An example interaction: Enter a char: A The char is:...
Question 5 (1 point) Using the following declarations, identify the scope that applies to the variables a, b, c and d. c nst b 1 a = true; void f (double b) char c for (int d = 0; d < 2; d++) cout << b << c << endl: 1. global 2. local
Which of the following would constitute a narrowing conversion in C++? Converting a char into an int. Converting an int into a short. Converting a float into a double. Converting a char into an int*.
S. Modułus operator can operate upon A. double B、 float C. char D. int E. C and D
In "C" Language
(Using Unions) Create union integer with members char c, short s, int i and long b. Write a program that inputs values of type char, short, int and long and stores the values in union variables of type union integer. Each union variable should be printed as a char, a short, an int and a long. Do the values always print correctly:? Sample input/output. To print in hexadecimal, use %x as the formatter. Input must be same...
Suppose the following declarations appear in the mainfunction of a C++ program: string name, qualification; char sex; int age, yearsExperience; If the following function header is given: void findCandidate (char sex, int & agep, string & name, int yearsExperience, string qualification) which of the options below is a correct calling statement of the function findCandidate in the main function? 1. findCandidate('m', 30, nameP, 7, "B. Curr"); 2. findCandidate (sex, age, name, yearsExperience, qualification); 3. findCandidate ('m', 30, name, 7, qualification);...