A) Give the output of the following programs:
i) #include<stdio.h>
void main()
{
char msg[]="Well Done";
for (int k=0; msg[k]; k++)
if (msg[k]==char(32))
msg[k]='*';
else
k%2==0 ? msg[k]++ : --msg[k];
printf(msg);
}
ii) #include<iostream.h>
int z=4;
void f(int& x, int y)
{
x+=y+=z+=x+y+z;
cout<<x<<","<<y<<","<<z<<endl;
}
void main()
{
int z=5;
f(z, ::z);
f(::z, z);
}
B) randomize()
for (int k=0; k<4; k++)
{
int r=5+random(5);
cout<<r;
}
What will the maximum value and minimum value stored in the variable r? What will be the output of the program segment?
i) 8642 ii) 9875 iii) 8769 iv) 3579
C) What is subscript? What is a subscripted variable? What is the restriction to be followed when a 2D array is passed as a parameter to the function?
Comments
Leave a comment