Topic – 2
Control Flow and Functions Control Flow
1 Mark Questions
Question 1:
Ronica Jose has started learning C++ and has typed the following program. When she compiled the following code written by her, she discovered that she needs to include some header files to successfully compile and execute it. Write the names of those header files, which are required to be included in the code.
void main() double X,Times,Result; cin>>X>>Times; Result=pow(X,Times); cout<<Result<<endl ;
All India 2016
Аnswer:
Ciostream. h>→cout, cin
<math. h>→pow()
Question 2:
Jayapriya has started learning C++ and has typed the following program. When she compiled the following code written by her, she discovered that she needs to include some header files to successfully compile and execute it. Write the names of those header files, which are required to be included in this code.
void main()
{
float A,Number,Outcome;
cin>>A>>Number;
Outcome=pow(A,Number);
cout<<Outcome<<endl;
} Delhi 2016
Аnswer:
<iostream.h>→cout, cin
<math.h>→pow( )
Question 3:
Ahmad has started learning C++ and has typed the following program. When he compiled the following code written by him, he discovered that he needs to include some header files to successfully compile and execute it. Write the names of those header files, which are required to be included in the code.
void main()
float Radians,Value;
cin>>Radians;
Value=sin(Radians);
cout<<value<<endl;
} All India 2016C
Аnswer:
<iostream.h>→cout, cin
<math.h>→sin( )
Question 4:
Observe the following C ++ code and write the name(s) of the header file(s), which will be essentially required to run it in a C ++ compiler.
void main()
{
float Area,Side;
cin>>Area;
Side=sqrt(Area);
cout<<"0ne Side of the Square:"<<Side<<endl;
} All India 2013
Аnswer:
<iostream.h>→ cout,cin
<math.h> →sqrt( )
Question 5 :
Observe the following C ++ code and write the name(s) of the header file(s), which will be essentially required to run it in a C++ compiler.
void main()
{
int Number;
cin>>Number;
if(abs(Number) == Number);
cout<<"Positive"<<endl;
} Delhi 2013
Аnswer:
<iostream.h>→ cout, cin
<math.h>→abs( )
Question 6:
Name the header file(s), which are essentially required to run the following program segment.
void main()
}
char A='K',B;
if(islower(A))
B=toupper(A);
else
B='*';
cout<<A<<"turned to"<<B<<endl:
} Delhi 2013C
Аnswer:
<iostream.h>→cout,cin
<ctype.h>→ islower( ); i supper( )
Question 7:
Write the names of the header files to which the following belong:
- puts( )
- sin( ) Delhi2009
Аnswer:
puts( )→<stdio.h>
sin( )→<math.h>
Question 8:
Write the names of the header files to which the following belong:
- setw( )
- sart( ) All India 2009
Аnswer:
setw( )→<iomanip.h>
sqrt( )→<math.h>
Question 9:
Write the names of the header files to which the following belong:
- puts( )
- randomizer( ) Delhi2009c
Аnswer:
puts( )→<stdio.h>
randomize( )→<stdlib.h>
2 Marks Questions
Question 10:
Rewrite the following C++ code after removing any/all syntactical errors with each correction underlined.
NOTE: Assume all required header files are already being included in the program.
void main()
{
cout<<"Enter an Alphabet:";
cin>>CH ;
switch(CH)
case 'A' cout<<"Ant";Break;
case ’B' cout<<"Bear”;Break;
} All India 2017
Аnswer:
The correct code is: void main() { char CH: cout<<”Enter an Alphabet:"; cin>>CH ; switch(CH) { case 'A': cout«"Ant"; break: case 'B'x cout<<"Bear"; break: } }
0 comments:
Post a Comment
Thanks for leaving a comment. As soon as it's approved, it will appear.