/  5
 
Computer SciencePractice Assignment
S.NO.SubPartQuestionMarksQ1.(a)What will be the output of the following program:#include <iostream.h> void Secret(char Str[ ]) {for (int L=0;Str[L]!='\0';L++);for (int C=0;C<L/2;C++)if (Str[C]=='A' || Str[C]=='E')Str[C]=Str[L-C-1];else{char Temp=Str[C];Str[C]=Str[L-C-1];Str[L-C-1]=Temp;}}void main(){ char Message[ ]="PreboardExam";Secret(Message);cout<<Message<<endl;}Ans.: maxEdraoberP(3)(b) void funnystr(char *s, int n = 2){int i = n;while(i < strlen(s)){s[i] = '-';i = i + n;}i = 0;while(s[i] != '\0'){if(s[i] > 'A' && s[i] < 'P')s[i] = tolower(s[i]);else if(s[i] > 'a' && s[i] < 'p'){if(i % 3 == 0)s[i] = tolower(s[i-1]);elses[i] = tolower(s[i]);}i++;}}void main(){char str[] = "MiCroSoFT";funnystr(str,3);(3)
1
 
cout<<str;}Ans.: mic-oS-fT(c)Give the output of the following program:#includevoid ReCode ( char Text[ ], int Num );void main ( ){char Note [ ] = "Butterfly";Recode (Note, 2);cout << Note <<endl;}void ReCode (char Text [ ], int Num){for ( int K = 0 ; Text [K] !='\0' ; K++)if ( K % 2 == 0)Text [K] = Text [K]- Num;else if ( islower (Text[K] ))Text [K] = toupper ( Text [K] )elseText[K] = Text[K] + Num;}Ans.: @UrTcRdLw3(d)What will be the output of the following program:#include<iostream.h>#include<string.h>void main( ){ char Mes1[ ]=”HuB”, Mes2[ ]=”ThaT”, Mes3[ ]=”BeSt”;int L1=strlen(Mes1), L2=strlen(Mes2), L3=strlen(Mes3);int N=L1+L2+L3;for(int c=0; c<N; c++){if(c%4==0){cout<<Mes2[L2-1];L2--;}elseif(c%3==0){cout<<Mes1[L1-1];L1--;}else{cout<<Mes3[L3-1];L3--;}}}Ans.: TtSBaeuBhH3
2
 
(e)Find the output of the following program (Assuming that all requiredheader files are included)void main( ){char NAME[ ] = “admiNStrAtiOn”;for( int x=0;x<strlen(NAME);x++){ if(islower(NAME[x]))NAME[x] = toupper(NAME[x]);elseif(isupper (NAME[x]))if(x%2==0)NAME[x] = NAME[x -1];elseNAME[x]--;cout<<NAME <<endl;}}Ans.: ADMIIRTRRTINN3(f)Find the output of the following program:#include<iostream.h>#include<ctype.h>void Secret(char Msg[ ], int N);void main( ){ char SMS[ ]=”rEPorTmE”;Secret(SMS,2);cout<<SMS<<endl;}void Secret(char Msg[ ], int N){ for(int C=0;Msg[C]!=’\0’;C++)if(C%2= =0)Msg[C]=Msg[C]+N;else if(isupper(Msg[C]))Msg[C]=tolower(Msg[C]);elseMsg[C]=Msg[C]-N;}Ans . teRmttoe(g)Find the output of the following program: (Assuming all header files areincluded)void Mycode(char Msg[],char C){ for(int i=0;Msg[i]!=’\0’;i++){if(Msg[i]>=’B’ && Msg[i]<=’H’)Msg[i]=tolower(Msg[i]);else if(Msg[i]==’A’ || Msg[i]==’a’)Msg[i]=C;else
3

Share & Embed

More from this user

Add a Comment

Characters: ...