Question

1.1 Assume that the variables a, b ,c, l and j are initialized as shown in...

1.1 Assume that the variables a, b ,c, l and j are initialized as shown in the following code fragment. What is the value of each variable after these statements are executed?(Please provide explanations) Int 1 =5 , J=2 , double a = 6 , b, c a) b =++l-j—, b) J =(int) b/2, c) a = + =b /J ,

Homework Answers

Answer #1

ANSWER:-

NOTE: c) a = + =b /J ; this wrong so i considered as a =+b/J;

a) b =++l-j—;

#include <iostream>
using namespace std;

int main() {
   int l=5 , J=2;
   double a=6,b,c; // default value of b,c is 0
   ++l-J--; // value of l will be 6 after increment of 1 and value of J will be 1 after decrement of 1
   J =(int) b/2; // default value of b is 0 so 0/2=0 means value of J will be 0
   a =+b/J; // 6+0/0= nan because 0/0 is arithmetic exception so give nan
   cout<<a<<" "<<b<<" "<<c<<" "<<l<<" "<<J;
   return 0;
}

so final value of all variables are :

a=-nan

b=0

c=0

J=6

l=0

// If any doubt please comment

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Given an int variable n that has already been declared and initialized to a positive value...
Given an int variable n that has already been declared and initialized to a positive value and another int variable j that has already been declared , use for loop to print a single line consisting of n asterisk. Thus if n contains 5 , five asterisks will be printed. Use no variables other than n and j. ( please use C standard)
1. Suppose that the integer variables n and m have been initialized. Check all the correct...
1. Suppose that the integer variables n and m have been initialized. Check all the correct statements about the following code fragment. String s2 = (n>=m) ? "one" : ( (m<=2*n) ? "two": "three" ); Question 5 options: If m is strictly greater than 2n then the value of s2 is "two" If n is equal to m then the value of s2 is "two" If m is strictly greater than 2n then the value of s2 is "three" If...
1. In C++, programmers can use a class to create a large number of instance variables...
1. In C++, programmers can use a class to create a large number of instance variables of the class's type. Group of answer choices True False 2. When a C++ programmer declares a function, they are required to state all of the following except Group of answer choices {} The type of data, if any, returned by the function The function name The type of data, if any, sent to the function 3. When a C++ programmer calls a function,...
write a statement that declares char variable named gender initialized to the character m in c++...
write a statement that declares char variable named gender initialized to the character m in c++ additionally, What is the value of number after the following code executes? int a=5; int b=10; int number = a++ + b++; lastly, The break; is required in every case block of a switch statement true or false and A default block is required in every switch statement true or false
Write the C55x assembly code for each of the following C snippet code shown below. Assume...
Write the C55x assembly code for each of the following C snippet code shown below. Assume the 8-bit values a, b, c, and d are stored in locations 0x600, 0x601, 0x602, and 0x603 respectively in the memory. Store the result x in location 0x604 and y in location 0x60C. Do not use software to generate the assembly code and comment your code. x = (a - b)3 - (c*d); for (j=0;j<=200;j++)   y = y + (a * b);
JAVA What values are stored in variables a and b in the code below? public class...
JAVA What values are stored in variables a and b in the code below? public class StackQuestion { public static void main(String[] args) { Stack s = new Stack(); s.push(1); s.push(2); s.push(3); s.pop(); s.pop(); s.push(4); s.push(5); s.pop(); s.pop(); int a = s.pop(); s.push(6); int b = s.pop(); } } What numbers are stored in variable a and b when the code below executes? public class QueueQuestion { public static void main(String[] args) { Queue s = new Queue(); s.enqueue(1); s.enqueue(2);...
30. Suppose sum and num are int variables, and the input is 15 18 20 -1...
30. Suppose sum and num are int variables, and the input is 15 18 20 -1 What is the output of the following code? (Assume that console is a scanner object initialized to the standard input device.) sum = console.nextInt(); num = console.nextInt(); while (num != -1) { num = console.nextInt(); sum = sum + num; } System.out.println(sum); a. 34 b.35 c.52 d.53 57. Which of the following statements would you use to declare the reference variable secretObject of type...
In this lab, we want to get some practice with pointers -- specifically, the basic syntax...
In this lab, we want to get some practice with pointers -- specifically, the basic syntax of declaring them, storing memory addresses into them, dereferencing them, and seeing how they work with pointer arithmetic in the context of built-in, C-style arrays. Unless specified otherwise, you can use any valid variable names you wish. The requirements for this program are as follows: Part A Declare a pointer-to-int, initialized to nullptr. Declare an int variable, initialized to some value of your choice....
if statement translation Using ARM assembly language, initialize the variables a, b, and c to consecutive...
if statement translation Using ARM assembly language, initialize the variables a, b, and c to consecutive integers starting at 1. Create your code so that a is in R0, b is in R1, and c is in R2. Build the following if statements, using the ARM Cortex-M0 instructions, in sequence in your code. Please put both if statement implementations in one file. Send me your .s file for grading. if a == 1 b = b * 4 + 2...
2. Consider the following program written in C syntax: void swap(int a, int b) {   ...
2. Consider the following program written in C syntax: void swap(int a, int b) {    int temp;    temp = a;    a = b;    b = temp; } void main() {    int value = 2, list[5] = {1, 3, 5, 7, 9};    swap(value, list[0]);    swap(list[0], list[1]);    swap(value, list[value]); } For each of the following parameter-passing methods, what are all of the values of the variables value and list after each of the three...