COMPUTER SCIENCE C++

1.b) Name the header file of C++ to which following functions belong. (i)strcat( )(ii) scanf( ) (iii) getchar( ) (iv)clrscr( )

Ans:

(i)strcat( ) - string.h
(ii)scanf( ) - stdio.h
(iii)getchar( ) - stdio.h
(iv)clrscr( ) - conio.h

1.c) Find the syntax error(s), if any, in the following program:

#include<iostream.h>
main( )
{ int x[5],*y,z[5];
for(i=0;i<5;i++)
{ x[i]=i;
z[i]=i+3;
y=z;
x=y;
}
}

Ans (i) Line No 5: Undefined symbol ‘i’. The variable ‘i’ is not declared in the program.(ii)Line No 10:Assign the value of a pointer to an integer variable. Ie error in x=y.

1.e) Write the output of the following program.

#include<iostream.h>
static int i=100;
void abc( )
{ static int i=8;
cout<<”first =”<<I;
}
main( )
{ static int i=2;
abc( );
cout<<”second =”<<i<<endl;
}

Ans: Output:

First =8second =2

1.f) Write a C++ function that converts a 2- digit octal number into binary number and prints the binary equivalent.

#include<iostream.h>
#include<conio.h>
void binary(int a)
//member function for conversion
{ int i,b[5]; //integer array 6
for(i=3;i>=1;i--)
{ b[i]=a%2;
a=a/2;
}
for(i=1;i<=3;i++)
cout<<b[i];
}
void main()
{ int n,x,y;
clrscr( );
cout<<"Enter a two digit octal number: ";
cin>>n;
x=n/10;
y=n%10;
binary(x);
binary(y);
getch( );

 

CBSE Computer Science Solved Revision Tour By Mr. Ravi Kiran ( mrkdata@yahoo.com )


Warning: include_once(../../ebooks-footer19.php): Failed to open stream: No such file or directory in /home/cbseguess/public_html/ebooks/xii/coumputer-science/cpp20.php on line 141

Warning: include_once(): Failed opening '../../ebooks-footer19.php' for inclusion (include_path='.:/opt/cpanel/ea-php83/root/usr/share/pear') in /home/cbseguess/public_html/ebooks/xii/coumputer-science/cpp20.php on line 141

Warning: include_once(../../../footer19.php): Failed to open stream: No such file or directory in /home/cbseguess/public_html/ebooks/xii/coumputer-science/cpp20.php on line 143

Warning: include_once(): Failed opening '../../../footer19.php' for inclusion (include_path='.:/opt/cpanel/ea-php83/root/usr/share/pear') in /home/cbseguess/public_html/ebooks/xii/coumputer-science/cpp20.php on line 143