Page 323 - C++
P. 323
(e) Find and write the output of the following C++ program code : 2
Note : Assume all required header files are already included in the
program.
#define Modify(N) N*3+10
void main()
{
int LIST[]={10,15,12,17};
int *P=LIST, C;
for(C=3; C>=0; C--)
LIST[I]=Modify(LIST[I]);
for (C=0; C<=3; C++)
{
cout<<*P<<":";
P++;
}
}
(f) Look at the following C++ code and find the possible output(s) from
the options (i) to (iv) following it. Also, write the highest and lowest
values that can be assigned in the array A. 2
Note :
Assume all the required header files are already being included in
the code.
The function random(n) generates an integer between 0 and n – 1.
void main()
{
randomize();
int A[4], C;
for(C=0; C<4; C++)
A[C]=random(C+1)+10;
for(C=3; C>=0; C--)
cout<<A[C]<<"@";
}
(i) (ii)
13@10@11@10@ 15$14$12$10$
(iii) (iv)
12@11@13@10@ 12@11@10@10@
91 4