Beruflich Dokumente
Kultur Dokumente
Remember to show steps and at the end write “final output of the program will be ……”
Ans: - 2
111:60
112:70
113:85
(1 Mark for each correct line of output)
Ans:
C
AA
LLL
IIII
FFFFF
OOOOOO
RRRRRRR
NNNNNNNN
IIIIIIIII
AAAAAAAAAA
9)Give the output of the following program (Assuming that all required header files are
included in the program) (2)
void main()
{
char a[]= “Exam-2011 AheAd”;
int i;
for(i=0; a[i]!= ‘\0’;i++)
{
if(a[i]>= 97 && a[i]<=122)
a[i] --;
else
if(a[i]>= ‘0’ && a[i]<= ‘9’)
a[i] = a[i -1];
else
if(a[i]>= ‘A’ && a[i]<= ‘Z’)
a[i]+ = 32;
else
a[i]= ‘#’;
}
puts(a);
}
Ans
ew`l######agdac
10. Find the output of the following program: 2
#include <iostream.h>
#include <ctype.h>
void Encrypt(char T[])
{
for (int i=0;T[i]!='\0';i+=2)
if (T[i]=='A' || T[i]=='E') T[i]='#';
else if (islower(T[i])) T[i]=toupper(T[i]);
else T[i]='@';
}
void main()
{
char Text[]="SaVE EArtH";//The two words in the string Text
//are separated by single space
Encrypt(Text);
cout<<Text<<endl;
}
Ans:
@a@E@E#rTH
Ans:
TiLeP550
AiLJP430
Ans.
11, 19, 6
25, 15, 35
35, 5, 45
Ans:
Jack Jill
Jack JillJohn
14. Give the output of the following program segment (Assuming all required header
files are included in the program): 3
# include<iostream.h>
# include<ctype.h>
void change (char* state, int &s)
{ int b = s;
for (int x = 0; s>=0; x++, s−−)
if ((x+s)%2)
*(state+x) = toupper(*(state+b-x));
}
void main ( )
{
char s[ ] = “Punjab”;
int b = strlen (s)−1;
change (s, b);
cout<<s<<”#”<<b;}
Ans:
BAJJAB#-1
Ans:
4#6#10#
12@18@30@36@
17) Find the output of the following program : 3
# include < iostream.h>
void Withdef (int HisNum = 30)
{
for (int I=20 ; I<= HisNum; I+=5)
cout<<I<<” ”;
cout<<endl;
}
void Control (int &MyNum)
{
MyNum+=10;
Withdef(MyNum);
}
void main ()
{
int YourNum=20;
Control (YourNum);
Withdef();
cout<<”Number=”<<YourNum<<endl;
}
Ans:
20 25 30
20 25 30
Number=30
19) Obtain the output from the following C++ program as expected to appear on the screen
after its execution. 2
Important Note :
- All the desired header files are already included in the code,
which are required to run the code.
void main()
{
char *Text=”AJANTA”;
int *P, Num[]={1,5,7,9};
P=Num;
cout<<*P<<Text<<endl;
Text++;
P++;
cout<<*P<<Text<<endl;
}
Ans:
1AJANTA
5JANTA
B#0
I#1
G#1
23) #include<iostream.h>
#include<ctype.h>
#include<conio.h>
#include<string.h>
void PointersFun(char Text[], int &count)
{
char *ptr=Text;
int length=strlen(Text);
for(; count<length-2; count+=2, ptr++)
{
*(ptr + count) = toupper( * (ptr + count) );
}
}
void main()
{
clrscr();
int position=0;
char Data[]= “ChangeString”;
PointersFun(Data, position);
cout<<Data<< “@”<< position;
cout.write(Data + 3, 4);
}
Ans:
ChaNgeStrIng@10
24)
Ans:
25)
Ans:
B:380
A:350
C:275