Note :
i)All the questions are compulsory .
ii)Programming Language : C++ .
a) What is the difference between Auto variables and Static variables? Give an example to illustrate the same. 2
b) Name the header files for the following functions 2
(1)cgets
(2)floor
(3)isalpha
(4) gets
c)In the following C++ program what is expected value of myscore from options (i) to (iv) given below. 2
#include<stdlib.h>
#include<iostream.h>
void main( )
{
randomize( );
int score[]={ 25, 20,34,56, 72, 63};
int myscore=score[2+random(2)];
cout<<myscore<<endl;
}
i) 25 ii) 34 iii) 20 iv) None of these
d)Give the output of thefollowing program (Assuming all required header files are included in the program ). 2
void swap(char &c1,char &c2)
{
char temp;
temp=c1;
c1=c2;
c2=temp;
}
void update(char *str)
{ int k,j,l1,l2;
l1 = (strlen(str)+1)/2;
l2=strlen(str);
for(k=0,j=l1-1;k<j;k++,j--)
{
if(islower(str[k]))
swap(str[k],str[j]);
}
for(k=l1,j=l2-1;k<j;k++,j--)
{
if(isupper(str[k]))
swap(str[k],str[j]);
}
}
void main()
{
char data[100]={"gOoDLUck"};
cout<<"Original Data : "<<data<<endl;
update(data);
cout<<"Updated Data "<<data;
}
e) Give the output of the following program segment : 3
void main()
{ int x[] = { 11,22, 33, 55, 112};
int *p = x ;
while(*p<110)
{
if(*p%3 !=0)
*p=*p+1 ;
else
*p=*p+2 ;
P++ ;
}
for( int i=4 ;i>=1 ;i--)
{
cout<<x[i]<< ‘*’ ;
if(i%3= =0 )
cout<<endl ;
}
cout<<x[0]*3<<endl ;
}
Last edited by hemalathaijt; March 23rd, 2012 at 03:06 PM.