QUESTIONS
QUESTIONS
ii) 245
2 4 5 245 = (010100101)2
010 100 101
iii) 472
4 7 2 472 = (100111010)2
100 111 010
1
PREPARED BY…, B.MOHAMED YOUSUF M.C.A., B.Ed., (PG ASST IN COMPUTER SCIENCE)
2. Write a C++ program to display numbers from 1 to 10. Except 5 using ‘for’ and ‘continue’ Statement. (M-2023)
#include<iostream>
using namespace std; Output:
int main() 1,2,3.4,6,7,8,9,10
{
int i;
for(i=1;i<=10;i++)
{
if(i==5)
{
continue;
}
cout<<i<<"\n";
}
return 0;
}
3. What is meant by computer ethics? (Aug-2022)
❖ Computer ethics deals with the procedures, values and practices that govern the process of consuming computer
technology and its related disciplines without damaging or violating the moral values and beliefs of any
individual, organization or entity.
❖ It is a set of moral principles that rule the behaviour of individuals who use computers.
❖ An individual gains knowledge to follow the right behaviour, using morals that are also known as ethics.
4. Write a c++ program to sum the numbers from 1 to 10 using ‘for’ loop. (M-2022)
#include <iostream> Output
using namespace std; The sum of 1 to 10 is 55
int main ()
{
int i,sum=0;
for(i=1; i<=10;i++)
{
sum=sum+i;
}
cout<<"The sum of 1 to 10 is "<<sum;
return 0;
}
5. Consider the following c ++ code and answer the questions S-2020
class Personal 1 Which type of Inheritance is shown in the program?
{ Multilevel inheritance
int admno,rno; 2 Specify the visibility mode of base classes.
Marks – Public visibility mode Personal- Private visibility mode.
protected: 3.Name the base class(/es) and derived class (/es).
char Name[20]; Base Class Personal Derived Class Marks and Result
public:
personal();
void pentry();
void Pdisplay(); };
class Marks:private Personal
{ int M
protected:
char Grade[5];
public:
Marks();
void Mentry();
void Mdisplay(); };
class Result:public Marks
{
float Total,Agg;
char remark[5];
result();
void Rcalculate(); void Rdisplay();
2
PREPARED BY…, B.MOHAMED YOUSUF M.C.A., B.Ed., (PG ASST IN COMPUTER SCIENCE)
6. Read the following C++ code and answer the questions given below. (M-2020)
#include<iomanip> QUESTIONS
#include<iostream> 1.What is the name of the class in the above program?
using namespace std; Answer: product
class product 2. What are the data members are the class?
{ Answer: code, quantity, price
int code, quantity;
float price; 3. What is the memory size of the objects p1,p2?
public: Answer: Memory allocation for object p1 12
void assigndata(); Memory allocation for object p2 12
void print();
int main()
{
product p1,p2;
cout<<”\n Memory allocation for object p1”<<sizeof(p1);
cout<<”\n Memory allocation for object p2”<<sizeof(p2);
return 0;
}
7. Write a short program to print following series: 1 3 5 7…75 (J-2019)
#include<iostream>
using namespace std;
int main() Output:
{ 1 3 5 7 9 11 13 15 …..75
int n;
for(int i=1;i<=75,i+=2)
cout<<i<< “\t”;
getch ( );
}
8. Read the following C++ code and answer the questions given below. (M-2019)
class student Questions:
{ 1) Identify the member of the class : m,n, add(), calc()
int m,n;
public: 2) What is size of the objects x1,x2 in memory? x1 =8 bytes x2 = 8 bytes
void add();
float calc();
}x1,x2;
3
PREPARED BY…, B.MOHAMED YOUSUF M.C.A., B.Ed., (PG ASST IN COMPUTER SCIENCE)