Chapter – 1 C++ Revision Tour

2008 Delhi:

1.b. Name the header files that shall be needed for the following code:

void main( )
{
char String[ ] = “Peace”;
cout << setw(2)<<String;
}

Ans. iomanip.h , iostream.h

1. c. Rewrite the following program after removing the syntactical error(s) if any. Underline each correction. 2

#include
<iostream.h>
void main( )
{
First = 10, Second = 20;
Jumpto(First;Second);
Jumpto(Second);
}
void Jumpto (int N1, int N2 = 20)
{
N1=N1+N2;
count<<N1>>N2;
}

Ans.

#include<iostream.h>
void Jumpto (int N1,int N2=20); //Prototype missing
void main( )
{
int First = 10, Second = 20; //Data type missing
Jumpto(First , Second); //Comma to come instead of ;
Jumpto(Second);
}
void Jumpto(int N1, int N2)
{
N1=N1+N2;
cout<<N1<<N2; //Output operator << required
}

1. d. Find the output of the following program; 3
#include<iostream.h>
#include<ctype.h>
void main( )
{
char Text[ ] = “Mind@work!”;
for(int I=0; Text[I]!=’\0’;I++)
{
if(!isalpha(Text[I]))
Text[I]=’*’;
else if(isupper(Text[I]))
Text[I]=Text[I]+1;
else Text[I] = Text[I+1];
}
cout<<Text;
}

Ans: Solution:
Text[ ] =


Warning: include_once(../../ebooks-footer19.php): Failed to open stream: No such file or directory in /home/cbseguess/public_html/ebooks/xii/coumputer-science/chapter1.php on line 138

Warning: include_once(): Failed opening '../../ebooks-footer19.php' for inclusion (include_path='.:/opt/cpanel/ea-php83/root/usr/share/pear') in /home/cbseguess/public_html/ebooks/xii/coumputer-science/chapter1.php on line 138

Warning: include_once(../../../footer19.php): Failed to open stream: No such file or directory in /home/cbseguess/public_html/ebooks/xii/coumputer-science/chapter1.php on line 140

Warning: include_once(): Failed opening '../../../footer19.php' for inclusion (include_path='.:/opt/cpanel/ea-php83/root/usr/share/pear') in /home/cbseguess/public_html/ebooks/xii/coumputer-science/chapter1.php on line 140