You are on page 1of 19

7/8/2019 Important Questions for Class 12 Computer Science (C++) - Pointers - Learn CBSE

NCERT SOLUTIONS RD SHARMA CLASS 12 CLASS 11 CLASS 10 CLASS 9

CBSE SAMPLE PAPERS LAKHMIR SINGH

Learn CBSE

Important Questions for Class 12 Computer


Science (C++) – Pointers
December 28, 2017 by Sastry CBSE

Important Questions for Class 12 Computer


Science (C++) – Pointers
Previous years Examination Questions
2 Marks Questions
Question 1:
Obtain the output from the following C++ program as expected to appear on the screen after its execution.
Delhi 2014
Important Note:
All the desired header les are already included in the code, which are required to run the code.

void main()
{
char*String="SARGAM";
int *Ptr, A[]={l,5,7,9};
Ptr=A;
cout<<*Ptr<<String<<endl;
String++;
Ptr+=3;
cout<<*Ptr<<String<<endl;
} Chat with us on WhatsApp

https://www.learncbse.in/important-questions-class-12-computer-science-c-pointers/ 1/19
7/8/2019 Important Questions for Class 12 Computer Science (C++) - Pointers - Learn CBSE

Аnswer:
NCERT SOLUTIONS RD SHARMA CLASS 12 CLASS 11 CLASS 10 CLASS 9
Output of the given program will be
1SARGAM
9ARGAM
CBSE SAMPLE PAPERS LAKHMIR SINGH

Question 2:
Obtain the output from the following C+ + program as expected to appear on the screen after its execution.
All India 2014.2013
Important Note:
All the desired header les are already included in the code, which are required to run the code.

void main()
{
char *Text = "AJANTA";
int *P,Num[] = {11,5,7,9};
P = Num;
cout<<*P<<Text<<endl;
Text++;
P++;
cout<<*P<<Text<<endl;
}

Аnswer:
Output of the given program will be
1AJANTA
5JANTA

Question 3:
Observe the following C+ + code carefully and obtain the output, which will appear on the screen
after execution of it.
Delhi 2013
Important Note:
All the desired header les are already included in the code, which are required to run the code.

void main()
{
char *String = "SHAKTI";
Chat with us on WhatsApp
int *Point, Value[]={10,15,70,19};

https://www.learncbse.in/important-questions-class-12-computer-science-c-pointers/ 2/19
7/8/2019 Important Questions for Class 12 Computer Science (C++) - Pointers - Learn CBSE

Point = Value;
NCERT SOLUTIONS RD SHARMA CLASS 12 CLASS 11 CLASS 10 CLASS 9
cout<<*Point<<String<<endl;
String++;
Point++;
CBSE SAMPLE PAPERS LAKHMIR SINGH
cout<<*Point<<String<<endl;
}

Аnswer:
Output of the given program will be
10SHAKTI
15HAKTI

Question 4:
Give the output of the following program segment: (Assuming, all desired header le(s) are
already included). Delhi 2013C

void main()
{
float *Ptr,Points[] = {120,50,30,40,10};
Ptr=Points;
cout<<*Ptr<<endl;
Ptr+=2;
Points[2]+=2.5;
cout<<*Ptr<<endl:
Ptr++;
(*Ptr)+=2.5;
cout<<Points[3]<<endl;
}

Аnswer:
Output of the given program will be
20
32.5
42.5

Question 5:
Find the output of the following program: All India 2012
Chat with us on WhatsApp

https://www.learncbse.in/important-questions-class-12-computer-science-c-pointers/ 3/19
7/8/2019 Important Questions for Class 12 Computer Science (C++) - Pointers - Learn CBSE

#include<iostream.h>
NCERT SOLUTIONS RD SHARMA CLASS 12 CLASS 11 CLASS 10 CLASS 9
#include<conio.h>
#include<ctype.h>
typedef char Str80[80];
CBSE SAMPLE PAPERS LAKHMIR SINGH
void main()
{
char *Notes;
Str80 Str="vR.zGooD";
int L=6;
Notes = Str;
while(L>=3)
{
Str[L]=isupper(Str[L])?
tolower(Str[L]);
toupper(Str[L]);
cout<<Notes<<endl;
L--;
Notes++;
getch();
}
}

Аnswer:
Output of the given program will be
vR.zGoOd
R.zGOOD
.zgOOD
ZgOOD

Question 6:
Find the output of the following program: Delhi 2012

#include<iostream.h>
#include<conio.h>
#include<ctype.h>
typedef char Txt80[80];
void main()
Chat with us on WhatsApp
{

https://www.learncbse.in/important-questions-class-12-computer-science-c-pointers/ 4/19
7/8/2019 Important Questions for Class 12 Computer Science (C++) - Pointers - Learn CBSE

char *PText;
NCERT SOLUTIONS RD SHARMA CLASS 12 CLASS 11 CLASS 10 CLASS 9
Txt80 Txt="Ur2GReAt";
int N=6;
PText=Txt:
CBSE SAMPLE PAPERS LAKHMIR SINGH
while(N>=3)
{
Txt[N]=isupper(Txt[N])?
tolower(Txt[N]);
toupper(Txt[N]);
cout<<PText<<endl;
N--;
PText++;
}
}

Аnswer:
Output of the given program will be
Ur2GReat
r2GREat
2GrEat
grEat

Question 7:
In the following program, what will be the possible output(s) from the following options (i), (ii), (iii) and
(iv)? Justify your answer. Delhi 2011C

#include<iostream.h>
#include<stdlib.h>
#include<string.h>
#include<conio.h>
void main()
{
clrscr();
char *Text="1234";
int L=strlen(Text);
randomize();
for(int I=0;I<L;I++)
Chat with us on WhatsApp
{

https://www.learncbse.in/important-questions-class-12-computer-science-c-pointers/ 5/19
7/8/2019 Important Questions for Class 12 Computer Science (C++) - Pointers - Learn CBSE

int Start=random(I)+1;
NCERT SOLUTIONS RD SHARMA CLASS 12 CLASS 11 CLASS 10 CLASS 9
char P=Text[Start];
cout<<P<<":";
} CBSE SAMPLE PAPERS LAKHMIR SINGH
getch();
}
(i) 1:3:2:4:
(ii) 2:2:3:2:
(iii) 2:2:4:4:
(iv) 2:2:2:3:

Аnswer:
The possible output will be (ii) 2:2:3:2: and (iv) 2:2:2:3:

Question 8:
Find the output of the following program : Delhi 2011

#include<iostream.h>
#include<conio.h>
void main()
{
int Track[] = {10, 25, 30, 55},*Striker;
Striker = Track;
Track[1] += 30;
cout<<"Striker"<<*Striker<<endl;
*Striker -= 10;
Striker++;
cout<<"Next@"<<*Striker<<endl;
Striker += 2;
cout<<"Last@"<<*Striker<<endl;
cout<<"Rest To"<<*Striker[0]<<endl;
}

Аnswer:
There is an error in last line, i.e. *Striker[0], so the program will not run. In case, if there is no subscript in
Striker pointer, then the output would be
Striker10
Next@55 Chat with us on WhatsApp

https://www.learncbse.in/important-questions-class-12-computer-science-c-pointers/ 6/19
7/8/2019 Important Questions for Class 12 Computer Science (C++) - Pointers - Learn CBSE

Last@55
NCERT SOLUTIONS RD SHARMA CLASS 12 CLASS 11 CLASS 10 CLASS 9
Rest To55

Question 9:
CBSE SAMPLE PAPERS LAKHMIR SINGH
Find the output of the following program: All India 2011

#include<iostream.h>
#include<conio.h>
void main()
{
int *Queen, Moves[]={11, 22, 33,44};
Queen = Moves;
Moves[2] += 22;
cout<<"Queen @"<<*Queen<<endl;
*Queen -= 11;
Queen += 2;
cout<<"Now@"<<*Queen<<endl;
Queen++;
cout<<"Finally@"<<*Queen<<endl;
cout<<"New 0rigin@"<<*Moves[0]<<endl;
}

Аnswer:
There is an error in last line, i.e. *Moves[0], so the program will not run. In case, if there is no subscript in
Moves pointer, then the output would be
Queen @11
Now@55
Finally@44
New 0rigin@0

Question 10:
Find the output of the following program:

#include<iostream.h>
#include<conio.h>
void main()
{
Chat with us on WhatsApp
int Numbers[]={2,4,8,10};

https://www.learncbse.in/important-questions-class-12-computer-science-c-pointers/ 7/19
7/8/2019 Important Questions for Class 12 Computer Science (C++) - Pointers - Learn CBSE

int *ptr = Numbers;


NCERT SOLUTIONS RD SHARMA CLASS 12 CLASS 11 CLASS 10 CLASS 9
for(int c=0;c<3;c++)
{
cout<<*ptr<<"@";
CBSE SAMPLE PAPERS LAKHMIR SINGH
ptr++;
}
cout<<endl;
for(c=0:c<4:c++)
{
(*ptr) *= 2;
--ptr;
}
for(c=1:c<4;c++)
cout<<Numbers[c]<<"#";
cout<<endl;
}

Аnswer:
Output of the given program will be
2@4@8@
8#16#20#

Question 11:
Find the output of the following program:

#include<iostream.h>
#include<conio.h>
void main()
{
int Array[]={4,6,10,12};
int *pointer = Array;
for(int i=1;i<=3;i++)
{
cout<<*pointer<<"#";
pointer++;
}
cout<<endl;
Chat with us on WhatsApp
for(i=1;i<=4;i++)

https://www.learncbse.in/important-questions-class-12-computer-science-c-pointers/ 8/19
7/8/2019 Important Questions for Class 12 Computer Science (C++) - Pointers - Learn CBSE

{
NCERT SOLUTIONS RD SHARMA CLASS 12 CLASS 11 CLASS 10 CLASS 9
(*pointer) *= 3;
--pointer;
} CBSE SAMPLE PAPERS LAKHMIR SINGH
for(i=l;i<5;i++)
cout<<Array[i-1]<<"@";
cout<<endl;
}

Аnswer:
Output of the given program will be
4#6#10#
12@18@30@36@

Question 12:
Give the output of the following program segment. (Assume, all required header les are included in
the program.)

void main()
{
int a=32,*X=&a;
char ch=65, &eco=ch;
eco+=a;
*X+=ch;
cout<<a<<','<<ch<<endl;
}

Аnswer:
Output of the given program will be
129,a

Question 13:
Identify the syntax error(s), if any, in the following program. Also, give reason for errors.

void main()
{
const int i=20;
const int *const ptr=&i; Chat with us on WhatsApp

https://www.learncbse.in/important-questions-class-12-computer-science-c-pointers/ 9/19
7/8/2019 Important Questions for Class 12 Computer Science (C++) - Pointers - Learn CBSE

(*ptr)++;
NCERT SOLUTIONS RD SHARMA CLASS 12 CLASS 11 CLASS 10 CLASS 9
int j=15;
ptr=&j;
} CBSE SAMPLE PAPERS LAKHMIR SINGH

Аnswer:
(*ptr)++ cannot modify a const object ptr-&j cannot modify a const object.

Question 14:
Give the output of the following program segment. (Assume, all required header les are included in
the program.)

void main()
{
int array[] = {2,3,4,51};
int *arptr=array;
int value=*arptr;
cout<<va1ue<<'\n';
value=*arptr++;
cout<<value<<'\n';
value=*arptr;
cout<<value<<'\n';
value=*++arptr;
cout<<value<<'\n';
}

Аnswer:
Output of the given program will be
2
2
3
4

Question 15:
Give the output of the following program segment. (Assume, all required header les are included in
the program.)

Chat with us on WhatsApp

https://www.learncbse.in/important-questions-class-12-computer-science-c-pointers/ 10/19
7/8/2019 Important Questions for Class 12 Computer Science (C++) - Pointers - Learn CBSE

void main()

{ NCERT SOLUTIONS RD SHARMA CLASS 12 CLASS 11 CLASS 10 CLASS 9

char *s="GOODLUCK";
for(int x=strlen(s)-1;x>=0;x--)
CBSE SAMPLE PAPERS LAKHMIR SINGH
{
for(int y=0;y<=x;y++)
cout<<s[y];
cout<<endl;
}
}

Аnswer:
Output of the given program will be
GOODLUCK
G00DLUC
G00DLU
GOODL
GOOD
GOO
GO
G

Question 16:
Give the output of the following program segment. (Assume, all required header les are included in
the program).

void main()
{
char *NAME="a ProFile";
for(int x=0;x<strlen(NAME);x++)
if(islower(NAME[x]));
else
if(isupper(NAME[x]))
if(x%2!=0)
NAME[x]=tolower(NAME[x-l]
else
NAME[x]--;
Chat with us on WhatsApp

https://www.learncbse.in/important-questions-class-12-computer-science-c-pointers/ 11/19
7/8/2019 Important Questions for Class 12 Computer Science (C++) - Pointers - Learn CBSE

cout<<NAME<<endl;

} NCERT SOLUTIONS RD SHARMA CLASS 12 CLASS 11 CLASS 10 CLASS 9

Аnswer:
CBSE SAMPLE PAPERS LAKHMIR SINGH
Output of the given program will be
a Orooile

Question 17:
Find and write the output of the following C++ program code: All India 2017 NOTE
Assume all required header les are already being included in the program.

void main()
{
int *Point, Score[]={100,95,150,75,65,120};
Point=Score;
for(int L=0;L<6;L++)
{
if((*Point)%10==0)
*Point /= 2;
else
*Point -= 2;
if((*Point)%5==0)
*Point /= 5;
Point++;
}
for(int L=5;L>=0;L--)
cout<<Score[L]<<"*";
}

Аnswer:
Given program will give error, i.e. Multiple declaration
for ‘L’ If we remove int from 2nd for loop then output will
be: 12*63*73*15*93*10*

Question 18:
Find the output of the following program: Delhi 2012C

Chat with us on WhatsApp

https://www.learncbse.in/important-questions-class-12-computer-science-c-pointers/ 12/19
7/8/2019 Important Questions for Class 12 Computer Science (C++) - Pointers - Learn CBSE

#include<iostream.h>
NCERT SOLUTIONS RD SHARMA CLASS 12 CLASS 11 CLASS 10 CLASS 9
void main()
{
int Points=300;
CBSE SAMPLE PAPERS LAKHMIR SINGH
int *Start=&Points;
int *End;
End=new int;
(*End)=Points-150:
Points+=100;
cout<<Points<<":"<<*Start<<endl;
cout<<*End<<endl;
Start=End;
cout<<Points<<":"<<*Start<<endl;
cout<<*End<<endl;
Points-=100;
*Start-=50;
cout<<Points<<":"<<*Start<<endl;
cout<<*End<<endl;
delete End;
}

Аnswer:
Output of the given program will be 400:400
150
400:150
150
300:100
100

Question 19:
Find the output of the following program Delhi 2009

#include<iostream.h>
#include<conio.h>
void main()
{
int X[]={10, 25, 30, 55, 110};
Chat with us on WhatsApp
int *p=X;

https://www.learncbse.in/important-questions-class-12-computer-science-c-pointers/ 13/19
7/8/2019 Important Questions for Class 12 Computer Science (C++) - Pointers - Learn CBSE

whi1e(*p<110)

{ NCERT SOLUTIONS RD SHARMA CLASS 12 CLASS 11 CLASS 10 CLASS 9


if(*p%3!= 0)
*p = *p+1;
CBSE SAMPLE PAPERS LAKHMIR SINGH
else
*p = *p+2;
p++:
}
for(int 1=4;I>=1;I--)
{
cout<<X[I]<<"*";
if(I%3 == 0)
cout<<endl;
}
cout<<X[0]*3<<endl;
}

Аnswer:
Output of the given program will be
110*56*
32*26*33

Question 20:
Find the output of the following program. Delhi (C) 2009

#include<iostream.h>
#include<conio.h>
struct score
{
int Year;
float topper;
};
void Change(score *s, int x=20)
{
s->topper=(s->topper+25)-x;
s->Year++;
}
Chat with us on WhatsApp
void main()

https://www.learncbse.in/important-questions-class-12-computer-science-c-pointers/ 14/19
7/8/2019 Important Questions for Class 12 Computer Science (C++) - Pointers - Learn CBSE

{
NCERT SOLUTIONS RD SHARMA CLASS 12 CLASS 11 CLASS 10 CLASS 9
score Arr[]={{2007, 100},{2008, 951}};
score *Point=Arr;
Change(Point, 50);
CBSE SAMPLE PAPERS LAKHMIR SINGH
cout<<Arr[0].Year<<"#"<<Arr[0].topper<<endl;
Change(++Point);
cout<<Point->Year<<"#"<<Point->topper<<endl;
}

Аnswer:
Output of the given program will be
2008#75
2009#100

Question 21:
Find the output of the following program. All India 2009

#include<iostream.h>
#include<conio.h>
void main()
{
int A[] = {10, 15, 20, 25. 30};
int *p = A;
whi1e(*p<30)
{
if(*p%3!= 0)
*p = *p+2;
else
*p = *p+1;
P++;
}
for(int J=0;J<=4;J++)
{
cout<<A[J]<<"*";
if(J*3 == 0)
cout<<endl;
}
Chat with us on WhatsApp

https://www.learncbse.in/important-questions-class-12-computer-science-c-pointers/ 15/19
7/8/2019 Important Questions for Class 12 Computer Science (C++) - Pointers - Learn CBSE

cout<<A[4]*3<<endl;

} NCERT SOLUTIONS RD SHARMA CLASS 12 CLASS 11 CLASS 10 CLASS 9

Аnswer:
CBSE SAMPLE PAPERS LAKHMIR SINGH
Output of the given program will be
12*
16*22*27*
30*90

Question 22:
What will be the output of the following program?

#include<iostream.h>
#include<ctype.h>
#include<conio.h>
#include<string.h>
void ChangeString(char Text[],int SCounter)
{
char *Ptr = Text;
int Length = strlen(Text);
for(;Counter<Length-2;Counter+=2,Ptr++)
{
*(Ptr+Counter)=toupper(*(Ptr+Counter));
void main()
{
int Position=0;
char Message[]="Pointers Fun";
ChangeString(Message, Position);
cout<<Message<<"@"<<Position;
}

Аnswer:
Output of the given program will be
PoiNteRs Fun@10

Question 23:
What will be the output of the following program?
Chat with us on WhatsApp

https://www.learncbse.in/important-questions-class-12-computer-science-c-pointers/ 16/19
7/8/2019 Important Questions for Class 12 Computer Science (C++) - Pointers - Learn CBSE

#include<iostream.h>
NCERT SOLUTIONS RD SHARMA CLASS 12 CLASS 11 CLASS 10 CLASS 9
#include<ctype.h>
#include<conio.h>
#include<string.h>
CBSE SAMPLE PAPERS LAKHMIR SINGH
void NewtextCchar String[],int &Position)
{
char *Pointer=String;
int Length=strlen(String);
for(;Position<Length-
2;Position+=2,Pointer++) {
*(Pointer+Position)=toupper(*(Pointer+Position));
}
}
void main()
{
clrscr();
int Location=0;
char Message[]="Dynamic Act";
Newtext(Message, Location);
cout<<Message<<"#"<<Location;
}

Аnswer:
Output of the given program will be
DynAmiC ACt#10

Computer Science Important Questions for Computer Science NCERT Solutions

Filed Under: CBSE

Search the site ...

Chat with us on WhatsApp

https://www.learncbse.in/important-questions-class-12-computer-science-c-pointers/ 17/19
7/8/2019 Important Questions for Class 12 Computer Science (C++) - Pointers - Learn CBSE

NCERT SOLUTIONS RD SHARMA CLASS 12 CLASS 11 CLASS 10 CLASS 9

CBSE SAMPLE PAPERS LAKHMIR SINGH

NCERT Solutions for Class 10 Science Chapter 1

NCERT Solutions for Class 10 Science Chapter 2

Metals and Nonmetals Class 10

carbon and its compounds class 10

Periodic Classi cation of Elements Class 10

Life Process Class 10

NCERT Solutions for Class 10 Science Chapter 7

NCERT Solutions for Class 10 Science Chapter 8

NCERT Solutions for Class 10 Science Chapter 9

NCERT Solutions for Class 10 Science Chapter 10

NCERT Solutions for Class 10 Science Chapter 11

NCERT Solutions for Class 10 Science Chapter 12

NCERT Solutions for Class 10 Science Chapter 13

NCERT Solutions for Class 10 Science Chapter 14

NCERT Solutions for Class 10 Science Chapter 15

NCERT Solutions for Class 10 Science Chapter 16

Class 12 Maths NCERT Solutions

Class 11 Maths NCERT Solutions


Chat with us on WhatsApp
NCERT Solutions for Class 10 Maths

https://www.learncbse.in/important-questions-class-12-computer-science-c-pointers/ 18/19
7/8/2019 Important Questions for Class 12 Computer Science (C++) - Pointers - Learn CBSE

NCERT Solutions for Class 9 Maths


NCERT SOLUTIONS RD SHARMA CLASS 12 CLASS 11 CLASS 10 CLASS 9
NCERT Solutions for Class 8 Maths

CBSE SAMPLE PAPERS LAKHMIR SINGH NCERT Solutions for Class 7 Maths

NCERT Solutions for Class 6 Maths

RD SHARMA SOLUTIONS NCERT SOLUTIONS

NCERT Solutions for Class 10


RD Sharma Class 12 Solutions RD Sharma Class 11
NCERT Solutions for Class 9
RD Sharma Class 10 RD Sharma Class 9
NCERT Solutions for Class 8
RD Sharma Class 8 RD Sharma Class 7
NCERT Solutions for Class 7
RD Sharma Class 6 TS Grewal Accountacy
NCERT Solutions for Class 6

SOCIAL PROFILES

Like us on Facebook Follow us on Twitter

Watch Youtube Videos NCERT Solutions App

NCERT Exemplar Problems

Chat with us on WhatsApp

https://www.learncbse.in/important-questions-class-12-computer-science-c-pointers/ 19/19

You might also like