What is the output of the following C program?
int x=1, y=2;
int * const ptr = &x;
ptr = &y;
printf("%d\n", *ptr);
What is the output of the following C program?
int x=1, y=2;
const int * ptr = &x;
ptr = &y;
printf("%d\n", *ptr);
What is the output of the following C program?
int x=1, y=2;
int * ptr = &x;
ptr = &y;
printf("%d\n", *ptr);
What is the output of the following C program?
int x=1, y=2;
const int * const ptr = &x;
ptr = &y;
printf("%d\n", *ptr);
Question 1: It gives error assignment of read-only variable 'ptr' Question 2: 2 Question 3: 2 Question 4: It gives error assignment of read-only variable 'ptr'
What is the output of the following C program? int x=1, y=2; int * const ptr...
A) Complete the following C program to produce the following output: Output: x = 1, y = 2, z = 3 x = 10, y = 15.000000, z = 4 x = 10, y = 15.000000, z = 50 Program: #include int main(void) { // complete this line printf(" x = %d, y = %d, z = %d \n", x, y, z); { // complete this line // complete this line printf(" x = %d, y = %f, z =...
Computer Science C++ Program What is the output? int num =5; int* ptr = # cout << ptr << endl; cout << &ptr << endl; cout << *ptr << endl; What are the values stored in the following array? Draw a simple picture of the array with indexes and show what each element should be. int arrayExample [4] = { 5 };
solve for the blank (make sure use C++) #include<stdio.h> int main() { int *ptr, *a; int b, c; int d[10]; b = 10 + 6; c = 10 + 1; ptr = &c; a = &b; for (b = 0; b < 10; b += 1) { d[b] = b + 2; } //*ptr = ____ //*a = ____ //b = ____ //c = ____ //d = ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ b =...
20) What is the output of the following segment of C code: int avg(int n, int* a); int main () { int array[4]={1,0,6,9}; printf("%d", avg(4, array)+ 1); system("pause"); return 0; } int avg(int n, int* a) { int i, sum=0; for (i=0;i<n;i++) { sum+=a[i]; } return sum/n; } a) 16 b) 5 c) 4 d) 8 21) What is the output of the following segment of C code: int x = 2; int y = 3;...
What is the output of the following? int x = 50, y = 60, z = 70; int* ptr; ptr = &x; *ptr += 10; ptr = &y; *ptr += 5; ptr = &z; *ptr -= 3; cout << x << “ ” << y << “ ” << z << endl; A) 10 5 2 B) 50 60 70 C) 60 65 67 D) 60 65 72
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...
1. What is the output of the following program? include <stdio.h> int wilma (int x) if (x<5) x = 7; return (x) int main (void) int x-1 x=wilma (x) ; printf ("%d", x); return (0) b)3 c) 4 d) 7 a) 1 e) none of these
the
answer should be in C
What is the output of the following: int whatIsThat(int * x); int main() int hold; int x[] = { 2,4,6,8); hold = whatIsThat(x); printf("%d, %d\n", x[0], hold); return 0; } int whatIsThat(int * a) { int i,sum=0; a[0] = a[O] + 6; for(i = 0; i <= 2; i++) (sum+= a[i]; a[i] = a[i] + 12; return sum; a. 20, 20 b. 20, 18 c. 18, 18 d. none of above What is the...
C Programming
What is the output of the following code? int x=5: x * = 3: printf("%d\n", x): x++: ++x: x = x/2: printf("%d\n", x): printf("%d\n", x++): printf("%d\n", ++x);
What will be the output of the following code int x = 5; int y = 2; f(x,y); printf(“%s \n”, (x/y > 2) ? “x is more than two times larger than y” : “x is less than or equal to 2*y\n ”); f(int x, int y) { x = 2*y; printf(“%s \n”, (x/y > 2) ? “x is more than two times larger than y” : “x is less than or equal to 2*y \n”); } a. x is...