public class HomeworkLibCode {
void a()
{
int a=5,b=6,c=7;
System.out.println(a---b--);
System.out.println(a---a--);
System.out.println(a+++b+++c);
}
void b()
{
int v1=10,v2=20;
if(v1+v2>30 || v2++>=21)
{
System.out.println("1 ."+v1+" "+v2);
}
else if (v2==20 && ++v1==11)
{
System.out.println("2 ."+v1+" "+v2);
}
else {
System.out.println("3 ."+v1+" "+v2);
}
}
void c()
{
int x=10,y=20;
x=x+(x+5);
System.out.println(x);
y=y+y++;
System.out.println(y);
}
public static void main(String args[])
{
HomeworkLibCode t=new HomeworkLibCode();
System.out.println("first section of code executed output from part a");
t.a();
System.out.println("second section of code executed output from part b");
t.b();
System.out.println("third section of code executed output from part c");
t.c();
}
}
Answer
Output from part a
-1
1
14
output from part b)
3 . 10 21
output from part c)
25
40
a) int a -5, b 6, c 7 System.out.printin(a--b-- System.out.printin(a---a- System.out.println (a+++b+++c) Output from part a)...
y-y+2 ; eise iflxc4) Output: else System.out.printin(y) 8. int x-5, y-3 if (xs 10) x x-2 else x-x+2; Output: System.out printin(y): 9. int x -8; while (x 0) system, out .printin ("ні") ; output: - 10. int x 5 do ) while (x > 23) System.out println(x): output: 11. int x 25, y 8 System.out.println (x+ y) 12. int [1 arrayi 12, 4, 6, 8, 10) int value 0; for (int a 0; a array1.1ength; a++) Output value + arrayl...
int a = 5, b = 4, c = -10; if(!(a>b++)) System.out.println("Value of a is: " + a); System.out.println("We are inside the if-statement!"); System.out.println("Value of b is: " + b); }else if (c%2 != 0 & c < 0){ //logical error (curly brace), syntax error c = c / 0; System.out.println(“We are now in the else section and c is a negative odd number!” + c); } else System.out.println(“c is even?”);...
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;...
PLEASE SOLVE THESE QUESTIONS Q.3.6 What does the following code output? int x = 8; int y = 2; while(x > 8) { X- y+=2; } System.out.println(y); Q.3.7 What does the following code output? System.out.println((2 + 3 - 5) * (3/3) + (5+5)); Q.3.8 What does the following code output? if((2 == 2) && (3 != 3) && ((5 + 1)==6){ System.out.println(true); else { System.out.println(false);
C++ output 6) What is the exact output of the following program? #include <iostream> using namespace stdi void zolo(int &a, int sb) int main int x = 5, y =8; zolo(x,y)i cout << "x " << x << endl ; cout << "y = "" << y << endl ; return o: void zolo(int &a, int &b) int v1 = b + a; ' int v2 = b-a; 3 a=v1;13
1. What is the output of the following code segment? int array[] = { 8, 6, 9, 7, 6, 4, 4, 5, 8, 10 }; System.out.println( "Index Value" ); for ( int i = 0; i < array.length; i++ ) System.out.printf( "%d %d\n", i, array[ i ] ); 2. What is the output of the following code segment? char sentence[] = {'H', 'o', 'w', ' ', 'a', 'r', 'e', ' ', 'y', 'o', 'u' }; String output = "The sentence...
(a)How many times does the code snippet given below display "Hello"? int x = 1; while (x != 15) { System.out.println ("Hello"); x++; } (b)What is the output of the following code fragment? int i = 1; int sum = 0; while (i <= 5) { sum = sum + i; i++; } System.out.println("The value of sum is " + sum); Quie 2 What is the output of the following snipped code? public class Test {...
7. What is the output of the following program? #include <iostream> int f(int n, int & v, int * p) { V = *p; v = y + 1; return n+ (*p); int main() { int n = 10; int m = 20; std::cout << fin, n, & m); a. 30. b. 31. c. 41. d. 42. e. An error occurs. 8. What is the output of the following program? Note that both the signature and the body of the...
With a Scanner object created as follows, what method do you use to read an int value? Scanner input = new Scanner(System.in); A. input.int(); B. input.nextInt(); C. input.integer(); D. input.nextInteger(); What is the output of the following code? x = 0; if (x > 0) System.out.println("x is greater than 0"); else if (x < 0) System.out.println("x is less than 0"); else System.out.println("x equals 0"); A. x is greater than 0 B. x is less than 0 C. x equals 0...
CS 101 - Fundamentals of Computer Important instructions . For problems 16 that ar e Write Y onin the more rade You may rest of the looked at for the 1. [3 pts] The value of 13 soundt More 05 2 is pick one) 1 6.5 а) error ) 6.5 12 . 2. [3 pts] What is the value of x after the following statements? (pick one) int x = 25, y = 5; x + 2y: 25+ = 225)...