void main()
{
int i,j=2;
for(i=0;i<3;i++)
if(j=i)
cout<<"Lotus ";
else
cout<<"Rose ";
}
Its result is Rose Lotus Lotus.. How? Explain it?
Answers were Sorted based on User's Feedback
Answer / nc
In the assignment operations...if the assigned value is 0
then it denotes false and for any other number 1,2,3...it
denotes true.So for i=0 i.e j becomes 0 means condition
becomes false so it displays Rose and for rest of the values
of i it displays Lotus.
Is This Answer Correct ? | 10 Yes | 0 No |
Answer / pasha nitw
i think u confused at step 5
if(j=i) is different from if(j==i)
where as in if(j=i)
first i value assigned to j value for entire loop
then it cheks the expression.
according to this
if(0)
if(1)
if(2)
.
.
.
.
Is This Answer Correct ? | 6 Yes | 2 No |
1+1/2!+1/3!+...+1/n!
i really need help about this.. write a program to display the set of odd and even numbers separately. find the highest and lowest value of the given numbers.
solve the problem in the programming language C++"if a five digit number is input through the keyboard.Write a program to calculate the sum of its digits(hint: use the modulus operator)
i don't know about working of nested for loop can any one help me
How reader and writer problem was implemented and come up with effective solution for reader and writer problem in case we have n readers and 1 writer.
find level of following tree (state, parent) " J,D I,D H,C E,B F,B G,C B,A D,A C,A A,& K,E L,E L,F M,F N,G O,H P,I P,H Q,I R,J S,K U,P T,L
write a program that calculate the volume of cylinder after user enters radius and height and show the algorithm used
1 Answers Jomo Kenyatta University,
Code for Small C++ Class to Transform Any Static Control into a Hyperlink Control?
Complexity T(n) Write a linear-time algorithm that sorts n distinct integers, each of which is between 1 and 500. Hint: Use a 500-element array. (Linear-time means your algorithm runs in time c*n + b, where c and b are any constants that do not depend on n. For example, your algorithm can run in time n, or time 2n + 1, or time 5n + 10, or time 100n + 6, but not time c*n*n = c*n?.)
Assume in University Every student in university as entity, prepare a class for student that store the roll no, name, dob of student, and make funtion of deletion, manipulation, addition of student record.
Create a program to read two random data set in two files named data1.txt and data2.txt manifold contains integer numbers, whereas data2.txt file contains the float type numbers. Simpanlahmasing each into 2 pieces of data that is an array of type integer array and an array of type float, then calculate the average numbers in the second array.
What output does this program generate as shown? Why? class A { A() { cout << "A::A()" << endl; } ~A() { cout << "A::~A()" << endl; throw "A::exception"; } }; class B { B() { cout << "B::B()" << endl; throw "B::exception"; } ~B() { cout << "B::~B()"; } }; int main(int, char**) { try { cout << "Entering try...catch block" << endl; A objectA; B objectB; cout << "Exiting try...catch block" << endl; } catch (char* ex) { cout << ex << endl; } return 0; }