0% found this document useful (0 votes)
72 views

Class Xi Strings: Work Sheet No: 7

The document contains 9 questions related to C++ strings and string manipulation functions. It asks the reader to write code snippets to perform tasks like changing the case of characters, modifying strings based on conditions, defining user functions, and more. It also asks the reader to analyze code snippets and predict their output.

Uploaded by

Anushka
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
72 views

Class Xi Strings: Work Sheet No: 7

The document contains 9 questions related to C++ strings and string manipulation functions. It asks the reader to write code snippets to perform tasks like changing the case of characters, modifying strings based on conditions, defining user functions, and more. It also asks the reader to analyze code snippets and predict their output.

Uploaded by

Anushka
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

WORK SHEET No : 7

CLASS XI

Strings

Date : 13-12-14

1. Write the output of the code given


void main ( )
{ char Msg [ ] = OpEnSoURce ;
CONVERT (Msg , 2 );
cout<< Msg << endl;
}
void CONVERT ( char Info [ ] , int N )
{ for ( int C = 0 ; Info [ C ] ! = \0 ; C++)
if ( C%2 == 0 )
Info [ C] = Info [C] - N;
else
if ( islower ( Info [C] ) )
Info [C] = toupper ( Info [ C] );
else
Info [ C] = Info [ C ] + N ;
}

2. Write the output of the follwoing program segment


char NAME[ ] ="ComPUteR";
for(int x=0;x<strlen(NAME);x++)
if(islower(NAME[x]))
NAME[x]=toupper(NAME[x]);
else
if(isupper(NAME[x]))
if(x%2==0)
NAME[x]=tolower(NAME[x]));
else
NAME[X]=NAME[x-1];
puts(NAME);
3. Write a user defined function to check if a word is present in a string or
not

4. Write the output of the follwoing program segment


void main()
{ char NAME[] = a ProFiLe!;
for(int x=0;x<strlen(NAME);x++)
if(islower(NAME[x]))
NAME[x]=toupper(NAME[x]);
else
if(isupper(NAME[x]))
if(x%2!=0)
NAME[x]=tolower(NAME[x-1]);
else
NAME[x]--;
cout<<NAME<<endl;
5. Choose the correct options
void main( )
{
randomize( );
int p=99,q=999;
int x=random(3)+4;
int y=random(2)+2;
for(int i=0;i<x;i++)
cout<<#;
cout<<p<<-;
for(i=0;i<y;i++)
cout<<@;
cout<<q<<endl;
}
i. ##99-@999
ii. ##99-@@999
iii. ######99-@@999
iv. ####99-@@@
6 Name the header files(s) used for successive compilation of the following:
void main( )
{
char word[30];
strcpy ( word, Pre Board Examination );
int s = strlen (word);
if(s%2= = 0)
cout<<setw(20)<<word;
}

7. Write the output of the follwoing program segment


void manipulate( char string[], int&len)

{
for(int i=0; string[i]!=\0;i++)
{
if (isupper(string[i]))
{ string[i]= string[i]-2; len++; }
else
if (isupper(string[i]))
{string[i]=string[i+2]; len; }
else
string[i]=@;
}}
void main( )
{ char word[]= FuNUnliMiTEd!! ;
int length=strlen(word);
manipulate (word, length );
cout<<Word <<word<<@<<Length<<length;
}
8. Write a User defined function to check the position of a substring in a string . if the substring is present
9. Write a program convert the given string as shown if the string is
Eg :-

I have Ten chocolates


I evah neT setalocohc

You might also like