Search This Blog

Sunday, May 3, 2009

Assignment1

Assignment 01

Q1What will be the output of following code:

(a) What will be the output of the following program segment :
#include
void main( )
{
int r ,x , y;
x =50;
y = 10;
r = ( x > 45 ) ? x : y;
cout << r ;
}
(b) What will be the output of the following program segment :
#include
void main( )
{
int I = 0, x = 0;
do
{
if ( I % 5 = = 0 )
{
x + +;
cout< }
+ + I;
} while ( I < 20 )
cout<< “\n”<< x;
}

Q3. Write a loop to access all the elements of 1-D of size 10
1. from left to right
2. from right to left(reverse order)
3. only the first half
4. only the second half
5. first and second half together (using 2 variable)

2 comments:

  1. mam i didn't get the last question.( Q3.-5)
    can u plz explain???
    and where should i post d answers????????
    on u'r id??

    ReplyDelete
  2. Anchit
    in the last question you need two variables one to increment value from 0 to n/2 and another variable initalized as n-1 and decrement till n/2

    ReplyDelete