Answers
1. c.C
2. b. displays A and B
3. c. The larger of x and y is stored in z unless x and y are equal, in which case z is assigned to 0
4. e. blue green yellow
there is no break statement after blue and green
5. b. 4
it doesn't enter if condition
6. d. x = x * ( i + j );
7. c. 9
x > 4 is true so (x > 4) = 1
x <= 4 is false so (x<=4) = 0
1*9 + 0*5 = 9
8. e. expression is invalid
we need to pass character so function call should be cat('W');
Multiple Choices (1 point each) to the program segment at the right is 85, what is...
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 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...
Consider the following pseudo code. What are the possible outputs (.e., the complete output from each execution run of this program)? Explain in less than 50 words. Note: keep in mind that fork) may fail in that case no child process is created int main(int arge, char argvt int X- int CwO; re - fork(); 15 tre > 0) X=S; else x-rc +2: printf(" \n", x); return 0;
5.43 (10 pts) What does the following program do? #include <stdio.h> 3 unsigned int mystery Cuns igned int a, unsigned int b): // function prototype 5 int main(void) printf("%s". "Enter two positive integers: unsigned int x: I/ first integer unsigned int y: // second integer scanf("Su%u". &x, &y); "); 12 13 14 15 II Parameter b must be a positive integer 16 to prevent infinite recursion 7 unsigned int mystery Cuns igned int a, unsigned int b) 18 printf("The result...
C program take values to 9 and the second can take values to 12 if (x > 2^3) printf("d", x); Int s-e; 21. LOST) Write a statement that declare an array of doubles with two indices, such that the first index can 22 (LOL) The following code will print out: 23. (L02.) The following code will print out: PART 2 Fill in the banks questions 3 marts x + 5; else x -- 2; char "stri - "abcd"; char str2[]...
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);...
12. if x = 0x25 then which of the following statements is correct a) if y = x | (1<<1) then y is 0x26 b) if y = x << 1 then y is 0x4A Review questions COMP 2401 Fall 2019 Page 4 of 14 c) if y = x & 0x37 then y is 0x35 d) if y = x | 0x37 then y is 0x35 e) All of the above statements are incorrect 13. What will be the...
write solution to the program above in C please and thank you. Output all combinations of character variables a, b, and c. If a x,b-y, and c z, then the output is Your code will be tested in three different programs, with a, b, c assigned with Χ. 'y', 'z', then with #. 'S. %, then with T, 23 1 #include 3 int main(void) { char a char b; char c; 4. 7 scanf(" scanf(" scanf(" %c %c %c ",...
should be in C language What is the output of the following segment of C code: void CapsLetter (char* x, charl); int main() { char* text; text="This is some sample text."; CapsLetter(text, 'e'); printf("%s", text); return 0; سی void Caps Letter (char* x, char 1) { int i=0; while (x[i]!='\0') { if (x[i]==1) x[i]=1-32; } 1. This is som sample text. 2. THIS IS SOME SAMPLE TEXT. 3. This is some sample text. 4. this is some sample text. What...
QUESTION 1 What will be displayed as a result of executing the following code? int x = 5, y = 20; x += 32; y /= 4; cout <<"x = " << x <<"y = " << y; A. x = 32, y = 4 B. x = 9, y = 52 C. x = 37, y = 5 D. x = 160, y = 80 8 points QUESTION 2 What will be the displayed when the following code...