Saturday 20th April 2024
REGISTRATION
Online Fashion Store

CBSE eBooks

CBSE Guess > eBooks > Class XII > Computer Science By . Mr. MRK

Chapter – 1 C++ Revision Tour

Previous Index Next

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[ ] =

Previous Index Next