<div class=”entry-content” style=”height: auto !important;”><h2><span style=”color: #00ccff;”><strong>NCERT Solutions for Class 12 Computer Science (C++) – Pointers</strong></span></h2>
<p style=”text-align: center;”><span style=”color: #0000ff;”><strong>Very Short Answer Type Questions [1 mark each]</strong></span></p>
<p><span style=”color: #eb4924;”><strong>Question 1:</strong></span><br>
Write the definition of a function FixPay (float Pay[ ], int N) in C+ + , which should modify each element of the array Pay having N elements, as per the following rules :</p><div class=”code-block code-block-1″ style=”margin: 8px 0; clear: both;”>
<script async=”” src=”//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js” type=”text/javascript”></script>
<ins class=”adsbygoogle” style=”display: block; height: 280px;” data-ad-client=”ca-pub-7398766921532682″ data-ad-slot=”8094000682″ data-ad-format=”auto” data-adsbygoogle-status=”done” data-ad-status=”filled”><div id=”aswift_1_host” style=”border: none; height: 280px; width: 750px; margin: 0px; padding: 0px; position: relative; visibility: visible; background-color: transparent; display: inline-block; overflow: visible;” tabindex=”0″ title=”Advertisement” aria-label=”Advertisement”><iframe id=”aswift_1″ name=”aswift_1″ style=”left:0;position:absolute;top:0;border:0;width:750px;height:280px;” sandbox=”allow-forms allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts allow-top-navigation-by-user-activation” width=”750″ height=”280″ frameborder=”0″ marginwidth=”0″ marginheight=”0″ vspace=”0″ hspace=”0″ allowtransparency=”true” scrolling=”no” src=”https://googleads.g.doubleclick.net/pagead/ads?client=ca-pub-7398766921532682&output=html&h=280&slotname=8094000682&adk=2916952469&adf=4186660919&pi=t.ma~as.8094000682&w=750&fwrn=4&fwrnh=100&lmt=1670014485&rafmt=1&format=750×280&url=https%3A%2F%2Fwww.cbsetuts.com%2Fncert-solutions-class-12-computer-science-c-pointers%2F&fwr=0&rpe=1&resp_fmts=3&wgl=1&uach=WyJXaW5kb3dzIiwiMTAuMC4wIiwieDg2IiwiIiwiMTA4LjAuNTM1OS4xMjUiLFtdLGZhbHNlLG51bGwsIjY0IixbWyJOb3Q_QV9CcmFuZCIsIjguMC4wLjAiXSxbIkNocm9taXVtIiwiMTA4LjAuNTM1OS4xMjUiXSxbIkdvb2dsZSBDaHJvbWUiLCIxMDguMC41MzU5LjEyNSJdXSxmYWxzZV0.&dt=1672584785317&bpp=5&bdt=976&idt=314&shv=r20221207&mjsv=m202212050101&ptt=9&saldr=aa&abxe=1&cookie=ID%3D70877dca39d7cee1-22c4db3411d900f8%3AT%3D1672348851%3ART%3D1672348851%3AS%3DALNI_MYJDyG_bu32YHEUMIGJIo2bVt3_WQ&gpic=UID%3D00000b9a5c88ec58%3AT%3D1672348851%3ART%3D1672575613%3AS%3DALNI_Mb87E1-6Z_pG79EP2w2fRKpjdy0KA&prev_fmts=0x0&nras=1&correlator=6360370804552&frm=20&pv=1&ga_vid=540223204.1672348852&ga_sid=1672584786&ga_hid=1119097889&ga_fc=1&u_tz=330&u_his=12&u_h=768&u_w=1366&u_ah=728&u_aw=1366&u_cd=24&u_sd=1&dmc=4&adx=105&ady=576&biw=1349&bih=657&scr_x=0&scr_y=100&eid=44759875%2C44759926%2C44759837%2C44778780%2C31071168%2C44780792&oid=2&pvsid=4123133410701996&tmod=1209859931&uas=0&nvt=1&ref=https%3A%2F%2Fwww.learncbse.in%2F&eae=0&fc=1920&brdim=0%2C0%2C0%2C0%2C1366%2C0%2C1366%2C728%2C1366%2C657&vis=1&rsz=%7C%7CeE%7C&abl=CS&pfx=0&fu=128&bc=31&ifi=2&uci=a!2&fsb=1&xpc=1B7BBNnAfB&p=https%3A//www.cbsetuts.com&dtd=354″ data-google-container-id=”a!2″ data-google-query-id=”CN-K_O_PpvwCFQ8-lgodgscGuA” data-load-complete=”true”></iframe></div></ins>
<script type=”text/javascript”>
(adsbygoogle = window.adsbygoogle || []).push({});
</script></div>
<table border=”2″>
<tbody>
<tr>
<td style=”padding-left: 30px;”><strong>Existing Salary Value</strong></td>
<td style=”padding-left: 30px;”><strong>Required Modification in Value</strong></td>
</tr>
<tr>
<td style=”padding-left: 30px;”>If less than 1,00,000</td>
<td style=”padding-left: 30px;”>Add 25% in the existing value</td>
</tr>
<tr>
<td style=”padding-left: 30px;”>If >=1,00,000 and <20,000</td>
<td style=”padding-left: 30px;”>Add 20% in the existing value</td>
</tr>
<tr>
<td style=”padding-left: 30px;”>If >=2,00,000</td>
<td style=”padding-left: 30px;”>Add 15% in the existing value</td>
</tr>
</tbody>
</table>
<p><span style=”color: #eb4924;”><strong><span style=”color: #008000;”>Аnswer:</span></strong></span></p>
<pre>Void FixPay(float Pay[],int N)
{
for(int i=0;i<N;i++)
{
if(Pay[i]<100000)
Pay[i]+= Pay[i]*0.25;
else if(Pay[i]<200000)
Pay[i]+= Pay[i]*0.20;
else
Pay[i]+= Pay[i]*0.15 ;
}
}</pre>
<p><span style=”color: #eb4924;”><strong>Question 2:</strong></span><br>
Write the definition of a member function INSERT() for a class QUEUE in C+ +, to remove a product from a dynamically allocated Queue of items considering the following code is already written as a part of the program.</p>
<pre>Struct ITEM
{
int INO; char INAME[20];
ITEM*Link;
};
class QUEUE
{
ITEM *R,*F;
Public:
QUEUE(){R=NULL; F=NULL;}
void INSERT();
void DELETE();
~QUEUE();
};</pre>
<p><span style=”color: #eb4924;”><strong><span style=”color: #008000;”>Аnswer:</span></strong></span></p>
<pre>Void QUEUE::INSER()
{
ITEM*newitem = new ITEM;
Cout<<”enter item number”;
cin>>newitem → INO;
Cout<<”Enter item name”;
gets(newitem → INAME);
newitem → Link = NULL;
if (R==NULL)
R=F=newitem;
else
{
R → Link=newitem;
R = newitem;
}</pre>
<p style=”text-align: center;”><span style=”color: #0000ff;”><strong>Short Answer Type Questions-I</strong></span></p>
<p><span style=”color: #eb4924;”><strong>Question 1:</strong></span><br>
Write the output from the following C+ + program code :</p>
<pre>#include<iostream.h>
#include<ctype.h>
void strcon(char s[])
{
for(int i=0,l=0;s[i]!=’\0′;i++,l++);
fortint j=0;j<l;j++)
{
if(isupper(s[j]))
s[j]=tolower(s[j])+2;
else if( islower(s[j]))
s[j]=toupper(s[j])-2;
else
s[j] =’@’;
}
}
void main()
{
char *c=”Romeo Joliet”;
strcon(c);
cout<<”Text=”<<c<<endl;
c=c+3;
cout<<”New Text=”<<c<<endl;
c=c+5-2 ;
cout<<”last Text= “<<c;
}</pre>
<p><span style=”color: #eb4924;”><strong><span style=”color: #008000;”>Аnswer:</span></strong></span><br>
Text = tMKCM@lMJGCR<br>
New Text = KCM@1MJGCR<br>
Last Text = 1MJGCR</p>
<p><span style=”color: #eb4924;”><strong>Question 2:</strong></span><br>
Obtain the output of the following C+ + program as expected to appear on the screen after its execution.<br>
Important Note :<br>
All the desired header files are already included in the code, which are required to run the code.</p>
<pre>void main()
{
char *Text=”AJANTA”; int *P, Num[]={l,5,7,9}
P=Num;
cout <<*p<< Text <<endl;
Text++;
P++;
cout<<*P<<Text<<endl;
}</pre>
<p><span style=”color: #eb4924;”><strong><span style=”color: #008000;”>Аnswer:</span></strong></span><br>
1AJANTA<br>
5JANTA</p>
<p><span style=”color: #eb4924;”><strong>Question 3:</strong></span><br>
Obtain the output from the following C+ + program as expected to appear on the screen after its execution.<br>
Important Note :<br>
• Adi the desired header files are already included in the code, which are required to run the code<strong>.</strong></p>
<pre>void main()
{
char *String=”SARGAM”;
int *Ptr, a[]={1,5,7,9};
ptr=a;
cout<<*ptr<<String<<endl;
String++;
ptr+=3;
cout<<*ptr<<String<<endl;
}</pre>
<p><span style=”color: #eb4924;”><strong><span style=”color: #008000;”>Аnswer:</span></strong></span><br>
1 SARGAM<br>
9ARGAM</p>
<p><span style=”color: #eb4924;”><strong>Question 4:</strong></span><br>
Give the output of the following program segment: (Assuming all desired header file(s) are already included)</p>
<pre>void main()
{
float *Ptr, Points[] = {20,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;
}</pre>
<p><span style=”color: #eb4924;”><strong><span style=”color: #008000;”>Аnswer:</span></strong></span><br>
20.00 32.5<br>
42.50</p>
<p><span style=”color: #eb4924;”><strong>Question 5:</strong></span><br>
Find the output of the following code :<br>
Important Note :<br>
All the header files are already included in the code, which are required to run the code.</p>
<pre>void main()
{
char *String=”SHAKTI”;
int*Point,Value[]={10,15,70,19};
Point=Value;
cout<<*Point<<String<<endl;
String++;
Point++;
cout<<*Point<<String<<endl;
}</pre>
<p><span style=”color: #eb4924;”><strong><span style=”color: #008000;”>Аnswer:</span></strong></span><br>
10SHAKTI<br>
15HAKTI</p>
<p><span style=”color: #eb4924;”><strong>Question 6:</strong></span><br>
Write the output of the following C+ + program code :<br>
Note : Assume all required header files are already being included in the program.</p>
<pre>void change(int*s)
{
for(int i=0;i<4;i++)
{
if(*s<40)
{
if(*s%2==0)
*s=*s+10;
else
*s=*s+ll;
}
else
{
if(*s%2==0)
*S=*S-10;
else
*s=*s-ll;
}
cout<<*s<<” “;
s++;
}
}
void main()
{
int score[]={25,60,35,53 };
change(score);
}</pre>
<p><span style=”color: #eb4924;”><strong><span style=”color: #008000;”>Аnswer:</span></strong></span><br>
36 50 46 42</p>
<p style=”text-align: center;”><span style=”color: #0000ff;”><strong>Short Answer Type Question-II</strong></span></p>
<p><span style=”color: #eb4924;”><strong>Question 1:</strong></span><br>
Find the output of the following program :</p>
<pre>#include<iostream.h>
void in(int x,int y,int &z)
{
x+=y;
y–;
z*=(x-y);
}
void out(int z,int y,int &x)
{
x*=y;
y++;
z/=(x+y);
}
void main()
{
int a=20, b=30, c=10;
out(a,c,b);
cout<<a<<”#”<<b<<”#”<<c<<”#”<<endl;
in(b,c, a) ;
cout<<a<<”®”<<b<<”@”<<c<<”@”<<endl;
out(a,b,c);
cout<<a<<”$”<<b<<”$”<<c<<”$”<<endl;
}</pre>
<p><span style=”color: #eb4924;”><strong><span style=”color: #008000;”>Аnswer:</span></strong></span><br>
20#300#10#<br>
620@300@10@<br>
620$300$3000$</p>
<p style=”text-align: center;”><span style=”color: #0000ff;”><strong>Long Answer Type Questions</strong></span></p>
<p><span style=”color: #eb4924;”><strong>Question 1:</strong></span><br>
Find the output of the following code:</p>
<pre>#include<iostream.h>
void main()
{
int *Striker;
int Track[]={10,25,30,55};
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”<<*Track[0]<<endl;
}</pre>
<p><span style=”color: #eb4924;”><strong><span style=”color: #008000;”>Аnswer:</span></strong></span><br>
Striker 10<br>
Next@55<br>
Last@55<br>
Rest To 0</p>
<p><span style=”color: #eb4924;”><strong>Question 2:</strong></span><br>
Find the output of the following code :</p>
<pre>#include<iostream.h>
void main()
{
int *Queen;
Moves[]={ll,22,33,44};
Queen=Moves;
Moves[2]+=22;
cout<<”Queen@”<<*Queen<<endl;
*Queen-=ll;
Queen+=2;
cout<<”Now@”<<*Queen<<endl;
Queen++;
cout<<”Finally@”<<*Queen<<endl;
cout<<”NewOrigin@”<<*Moves[0]<<endl;
}</pre>
<p><span style=”color: #eb4924;”><strong><span style=”color: #008000;”>Аnswer:</span></strong></span><br>
Queen@11<br>
Now@55<br>
Finally@44<br>
NewOrigin@0</p>
</div>