Important Questions

CBSE Guess > Papers > Important Questions > Class XII > 2010 > Computer Science > Computer Science By MRK

CBSE CLASS XII

f. Write a function called zero_Small() that has two integer arguments being passed by reference and sets the smaller of the two numbers to 0. Write the main program to access this function. 4
#include<iostream.h>
#include<conio.h>
void zero_Small(int &A,int &B)
{ if(A<B)
A=0;
else
B=0;
}
void main( )
{ clrscr();
int a,b;
cout<<”Enter any two values…”;
cin>>a>>b;
cout<<"Initial values of a and b are ";
cout<<a<<" "<<b<<endl;
zero_Small(a,b);
cout<<endl<<"The final values of a and b are ";
cout<<a<<","<<b;
cout<<endl;
cout<<"\nPress any key to continue...";
getch();
}

2001

1.b. Name the header file to be included for the use of the following built in functions: (i)getc( ) (ii)strcat()

Ans.

  1. getc( ) - stdio.h
  2. strcat( ) - string.h

1.e) Give the output of the following program:
#include<iostream.h>
#include<conio.h>
int g=20;
void func(int &x,int y)
{ x=x-y;
y=x*10;
cout<<x<<’,’<<y<<’\n’;
}
void main( )
{ int g=7;
func(g,::g);
cout<<g<<’,’<<::g<<’\n’;
func(::g,g);
cout<<g<<’,’<<::g<<’\n’;
}

Ans: Output:
-13,-130
-13,20
33,330
-13,33

1.f. Write a function named SUMFIN( ), with arguments x, N, which returns the sum of N terms of the following series.: 4
x – x^3/3 + x^5/5 – x^7/7 + x^9/9
#include<iostream.h>
#include<math.h>
#include<conio.h>
double SUMFIN(int x1,int n1);
void main()
{ int x;
int n;
clrscr();
cout<<"Enter the vaue of X and N";
cin>>x>>n;
cout<<”\nThe sum of Series = “<<SUMFIN(x,n);
getch();
}
double SUMFIN(int x1,int n1)
{ double sum=0;
int c=0;
for(int i=1;i<=(2*n1);i=i+2)
{ c=c+1;
if(c%2==1)
{ sum=sum+(pow(x1,i))/i;
}
else
{ sum=sum-(pow(x1,i))/i;
}
}
return sum;
}

Paper By Mr. MRK
Email Id : [email protected]@yahoo.com