Explain what will be the output of following program
| A)
#include <iostrcam.h>
void main(void)
{ char str[] = "the boring stuff";
char *p = "that's interesting";
cout«endl«str;
cout«endl«p;
cout«endl«(void*)str;
cout«end 1 «(void')p;
B)
#include <iostream.h> #include <iomanip.h>
void main(void)
int i = 650;
float a = 425.123;
cout«setiosflags(ios::showbase/ios::uppcrcase); cout«i«endl; cout.precision(4);
cout«setiosflags(ios::showpoint)«a;
C) #include <math.h>
#include <sidio.h>
main(void)
{
double number = 123.54;
double down, up;
down = floor(number);
up = ceil(number);
printf("originaJ number %5.21f\n", number);
printf("number rounded down %5.21An", down);
printf("number rounded up %5.21f\n", up);
return 0;
)
D)
#include <stdio.h>
#include <string.h>
#include <conio.h>
main(void)
(
char string! 101;
char *strl = "computer";
clrscr();
slrncpy(string, str 1, 5);
string[3] = W;
printf("%s\n", string);
return 0;
}
B) public class A
{
int x = 4;
)
private class B :: class A
{
int x = 20;
cout « "x =" «x;
}
F;)
Explain scope resolution operator:: in C++ with suitable example.
i. A) Explain difference between public, private and protected class with C++ code. 5
B) What are the types of Inheritance ? Explain with suitable example. 5
3. A) Write a program to design a class for addition of two objects using friend
Function. 5
B) Write a C++ program to overload the operator '+', which will be used to
concat the two strings. 5
4. A) Write a program to demonstrate invocation of Constructor and Destructor. 5
B) Write a C++ program to swap two integer number and two real numbers.
Use templates. 5
5. A) Explain Runtime Type Information (RTTI) with suitable example. 5
B) Write a program to accept two numbers and perform basic mathematical operation on it.
Handle the exception like zero_divide_error. 5
6. Write a C++ program that reads the data from FILE1 .txt and copy every alternate
character to FILE2.txt. 10
B. A) Write a function powcr() to raise a number x to a power y. The function takes
a double value for x and int value for y, and returns result. Use default value 2
for y to make the function to calculate squares when this argument is omitted.
Write a main that gets the values of x and y from the user. 5
B) Write a C++ program illustrating static member function. 5
8. Define a class to represent a Bank Account. Include the following
Data Members: 10
a) Name of the Depositor. c) Type of Account
b) Account No. d) Balance Amount. Member Functions: l) To Assign initial value
b) To Deposit an amount
c) To Withdraw an amount
d) To Display Name of Depositor & Balance. Define all member functions and mainQ. Generate the saving account report slip as an output.
0 comments: