MENU

Chapter 1 C plus plus Revision Tour Solutions

Question - 1 : -
Write the related library function name based upon the given information in C++.

  1. Get single character using keyboard. This function is available in stdio.h file.
  2. To check whether given character is alpha numeric character or not. This function is available in ctype.h file.

Answer - 1 : -

  1. getchar( )
  2. isalnum( )

Question - 2 : -
Observe the following program very carefully and write the names of those header file(s),
which essentially needed to compile and execute the following program successfully :

typedef char TEXT[80];
void main()
{
TEXT Str[] = "Peace is supreme"; 
int Index = 0;
while(Str[Index]! = '\0')
if(isupper(Str[Index]"
Str[Index ++] = ? '#';
else
str[Index ++] = '*';
puts(Str);
}

Answer - 2 : -

,

Question - 3 : -
Name the header files that shall be needed for ‘ successful compilation of the following C+ + code :

void main()
{
char str[20],str[20];
gets(str);
strcpy(str1,str); 
strrev(str); 
puts(str); 
puts(str1);
}


Answer - 3 : -

#include
#include

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()
{
char CH, STR[20];
cin>>STR;
CH=toupper(STR[0]);
cout<
}

Answer - 4 : -

#include
#include

Question - 5 : -
Observe the following C++ code and write the name(s) of the header file(s), which will be essentially
required to rim it in a C++ compiler :

void main()
{
char Text[20],C;
cin>>Text;
C=tolower(Text[0]); 
cout<
}

Answer - 5 : -

#include
#include

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<
}

Answer - 6 : -

#include
#include

Question - 7 : -
Observe the following C+ + code and write the name(s) of header files, which will be essentially
required to run it in a C + + compiler

void main()
{
float Area, Side;
cin>>Area;
Side = sqrt(Area);
cout<<"one side of the square<
}

Answer - 7 : -

Header files required:

  1.  math.h
  2.  iostream.h

Question - 8 : -
Write the names of header files used :

void main()
{
int number; 
cin>>number;
if(abs(number) == number) 
×