
CBSE Guess > Papers > Important Questions > Class XI > 2010 >Computer Science >Computer Science By Mr. Ravi Kiran
CBSE CLASS XI

Q.7. Write the names of the header files of the following functions.
i)getch() ii) isalpha() iii)strcpy() iv)sqrt() 2
a) (i) getch( ) - conio.h (ii)isalpha( ) – ctype.h
(iii)strcpy( ) - string.h (iv)sqrt( ) - math.h
IV. Q. 1. Write a program to print the diagonal (left & right) elements of an N´N matrix. 4
a)//Program to print the left and right diagonal element of an NXN matrix
#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
void main( )
{ int A[10][10];
int i,j,N;
clrscr( );
cout<<"\nHow many rows and columns required for matrix: ";
cin>>N;
cout<<"\nEnter "<<N*N<<" elements: ";
for(i=0;i<N;i++)
{ cout<<"Enter the elements into Row "<<i+1<<": ";
for(j=0;j<N;j++)
cin>>A[i][j];
}
clrscr( );
cout<<"\nThe entered elements in the matrix are: \n";
for(i=0;i<N;i++)
{ for(j=0;j<N;j++)
cout<<A[i][j]<<"\t";
cout<<endl;
}
cout<<"\n\n\nThe elements which are belongs to only diagonals...\n";
for(i=0;i<N;i++)
{ for(j=0;j<N;j++)
if((i==j)||((i+j)==(N-1)))
cout<<setw(6)<<A[i][j];
else
cout<<" ";
cout<<endl;
}
getch( );
}
Q.2. Write a program to find the factorial of a number recursive function.
a) #include<iostream.h>
#include<conio.h>
long f=1;
long factorial(int n)
{ if (n==0)
return f;
else
f=n*factorial(n-1);
}
void main( )
{ clrscr( );
long num;
cout<<"\nEnter the number to which you want to find factorial: ";
cin>>num;
cout<<"\nThe factorial of the number = "<<factorial(num);
getch( );
}

Paper By Mr. Ravi Kiran
Email Id :mrkdata@yahoo.com
|