(Paper) Sample Paper Class - XII Computer Science 2008-2
Disclaimer: This website is NOT associated with CBSE, for official website of CBSE visit - www.cbse.gov.in
- void main()
{
const int i=20;
const int *const ptr=&i;
(*ptr)++;
int j=15;
ptr =&j;
}
- #include(iostream.h)
void main()
{
int X[]={60,50,30,40},Y; count=4;
cin>>Y;
for(i=count-1;i>=0;i--)
switch(i)
{
case 0;
case 2: cout<<Y*Y[i]<<endl; break;
case 1:;
cae 3: cout>>Y+X[i];
}
}
- struct group
{
int x1,x2;
}
void main()
{
g1,g2 group;
cin>>g1.x1<<g2.x2;
g2=g1;
cout<<g2.x2<<g2.x1<<endl;
2+=g1.x1;
cout<<g1.x1<<g1.x2;
}
- structure swimmingclub
{
int mem number;
char mamname[20]
char memtype[]=”LIG”;
};
void main()
{
swimmingclub per1,per2;
cin<<”Member Number”;
cin>>memnumber.per1;
cout<<”\n Member name”;
cin>>per1.membername;
per1.memtype=”HIG”;
per2=per1;
cin<<”\n Member number ”<<per2.memnumber;
cin<<”\n Member name “<<per2.memname;
cin<<”\n Member number “<<per2.memtype;
}
- #include<iostream.h>
CLASS STUDENT
{
int admno;
float marks;
public :
STUDENT()
{
admno=0;
marks=0.0;
}
void input()
{
cin>>admno;
cin>>marks;
}
void output()
{
cout<<admno;
cout<<marks;
}
}
void main()
{
STUDENT s;
input(s);
}
- #include<iostream.h>
void main()
{
struct STUDENT
{
char stu_name[20];
char stu_sex;
int stu_age=17;
}student;
gets(stu_name);
gets(stu_sex);
}
Output (5 marks)
- #include<iostream.h>
void display(char *s)
{
for(int x=0;s[x]>0;x++)
{
for(int y=0;y<=x;y++)
cout<<s[y];
cout<<endl;
}
}
void main()
{
char *t=”LAND”;
display(t);
}
- #include<iostream.h>
int &max (int &x,int &y)
{
if(x>y)
return (x);
else
return (y);
}
void main()
{
int A=10,B=13;
max(A,B)=-1;
cout<<”A= “<<A<<”B= “<<B<<endl;
max(B,A)=7;
cout<<”A= “<<A<<”B= “<<B<<endl;
}
- #include<iostream.h>
#include<conio.h>
int main()
{
char string[]=”Pointers and strings”;
cout<<*(&string[2])<<endl;
cout.write(string+5,15).put(‘\n’);
cout<<*(string+3)<<”\n”;
return 0;
}
- #include<iostream.h>
int a=10;
void main()
{
void demo(int &,int,int*);
int a=20,b=5;
demo(::a,a,&b);
cout<<::a<<a<<b<<endl;
}
void demo(int &x,int y,int *z)
{
a+=x;
y*=a;
*z=a+y;
cout<<x<<y<<*z<<endl;
}
- char *S=”ObjeCT”;
int L=strlen(S);
for(int C=0;C<L;C++)
if(islower(S[C]))
S[C]=toupper(S[C]);
else
if(C%2==0)
S[C]=’E’;
else
S[C]=tolower(S[C]);
cout<<”New message :”<<S;
- #include<iostream.h>
void Execute(int &x,int y=200)
{
int temp=x+y;
x+=temp;
if(y!=200)
cout<<temp<<” “<<x<<” “<<y<<endl;
}
void main()
{
int a=50,b=20;
Execute(b);
cout<<a<<” “<<b<<endl;
Execute(a,b);
cout<<a<<” “<<b<<endl;
}
- #include<iostream.h>
void print(char *p)
{
p=”Pass”;
cout<<”\n Value is “<<p<<endl;
}
void main()
{
char *q=”Best Of luck”;
print(q);
cout<<”\n New value is “<<q;
}
- char *s=”GOODLUCK”;
for(int x=strlen(s)-1;x>0;x--)
{
for(int y=0;y<=x;y++) cout<<s[y];
cout<<endl;
}
- #include<iostream.h>
int a=3;
void demo(int x, int y,int &z)
{
a+=x+y;
z=a+y;
y+=x;
cout<<x<<” “<<y<<” “<<z<<endl;
}
void main()
{
int a=2,b=5;
demo(::a,a,b);
cout<<::a<<” “<<a<<” “<<b<<endl;
demo(::a,a,b);
}