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)
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)
mam i didn't get the last question.( Q3.-5)
ReplyDeletecan u plz explain???
and where should i post d answers????????
on u'r id??
Anchit
ReplyDeletein 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