answersLogoWhite

0


Want this question answered?

Be notified when an answer is posted

Add your answer:

Earn +20 pts
Q: What is the final value of x when the code int x for(x0 x10 x ) is run?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is difference between volatile int and const volatile int?

volatile int means the code and fom outside from code can changes the value but in const volatile int, code cannot changes the value but fron ouside can change the value


Source code for LinearSearch in java?

// Returns the index of n in ns or -1 if not found. public static final int linearSearch(final int n, final int[] ns) { for(int i = 0; i < ns.length; ++i) { // If found, return the index if(ns[i] == n) { return i; } } return -1; }


Must all final variables be compile time constants?

No, it is not mandatory. As long as a final variable is initialized only once during the sequence of the code flow, the compiler would not complain. Ex: public class Test { final int x; public void assignVal(int val){ if(val > 100) { x = val; } } } The above code will compile and run just fine as long as there is no other line in the code that assigns a value for x.


Design iterative and recursive alogrithm to find the minimum among n elements?

// returns the minimum value in ns - iterative public static final int findMinIterative(final int[] ns) { if (ns.length == 0) { return 0; // return 0 if ns is an empty array } // search each element of ns int min = ns[0]; for (int i = 0; i < ns.length; ++i) { // if an element smaller than min is found, store that as the new min if (ns[i] < min) { min = ns[i]; } } return min; } // returns the minimum value in ns - recursive // Note that this problem does not lend itself to recursion; the solution is very similar to the iterative approach public static final int findMinRecursive(final int[] ns) { if (ns.length == 0) { return 0; // return 0 if ns is an empty array } // start recursion return findMinRecursive(0, ns[0], ns); } // recursive part of algorithm private static final int findMinRecursive(final int i, final int min, final int[] ns) { // bounds check if (i >= ns.length) { return min; } // recurse on next value of ns return findMinRecursive(i + 1, Math.min(min, ns[i]), ns); }


What if you feed an int value and an unsigned int value?

Feed? What do you mean by that


What is the purpose of call by value in java?

Simple types are passed by value in Java. For example: void meth(int a) { // code } meth(34); // 34 is passed by value


What value is return by int main method?

1. A method declared as "int" returns an int value. 2. The main() method in Java is not declared as "int", but as "void", meaning it returns no value.


What is the C plus plus code to print all ASCII codes and the equivalent characters?

Although character data types such as char are intrinsically numeric, whenever you print a char you automatically print the symbol associated with the character code (the char's value), never the code. In order to print the code you must cast the character to a numeric data type, such as int. char c = 'A'; // ASCII value 65 decimal (0x41) std::cout << static_cast<int>(c); // puts the value 65 on std::cout


Given 2 int arrays a and b each length 3 return a new array length 2 containing their middle elements?

Java solutionpublic static final int[] getMiddle(final int[] a, final int[] b) {return new int[] {a[1], b[1]};}C solution void getMiddle(const int a[], const int b[], int ret[]) {ret[0] = a[1];ret[1] = b[1];}


What is the difference between declaration and initialization?

Perhaps an example will help. extern int value; /* declaration */ int value; /* definition */ int value= 20; /* definition with initialization */


Write a program to calculate the sum of the sequence number from 1 to n loop?

public static final int getSum(final int n) { int sum = 0; for(int i = 1; i <= n; ++i) { sum += i; } return sum; }


What are the qualifiers that an int can have at a time?

A signed int can take a value between -32768 to 32767 and an unsigned int can take a value 0 to 65535.