Explore topic-wise InterviewSolutions in Current Affairs.

This section includes 7 InterviewSolutions, each offering curated multiple-choice questions to sharpen your Current Affairs knowledge and support exam preparation. Choose a topic below to get started.

1.

“A variable created inside a function body” a. Default Variable b. Local Variable c. Global Variable d. Named Argument

Answer»

Answer: Local variable.

2.

Explain function call using pass by reference technique with an example.

Answer»

Pass by reference is another way of passing parameters to the function. Pass by reference or call by reference is the method by which the addresses of the variables (actual arguments) are passed to the called function. The symbol is used to refer the addresses of the variables to the called function. The changes made to the formal parameter will change values in the actual arguments.

For example:

#include<iostream>

void swap(int&x,int&y);//function declaration

int main()

{

//local variable declaration:

int a = 100;

int b = 200;

cout<<"Before swap,value of a:"<<a<<endl;

cout<<"Before swap,value of b:"<<b<<endl;

//calling a function to swap the values variable reference. swap(a,b);

cout<<"After swap,value of a:"<<a<<endl;

cout<<"After swap,value of b:"<<b<<endl;

return 0;

}

void swap(int&x,int&y)//fuction definition to swap the values.

{

int temp;

temp = x;/* save the at address x */

x = y;\*put y into x */

y = temp;/* put x into y */

return;

}

Before the function call, the values of a and b were 100 and 200 respectively. After the function, though no values are returned back to the main(), shows the value of a and b as 200 and 100 respectively. This is due to call by reference in which changes made in the formal argument will affect the values in the actual argument.

3.

What are the steps involved in hosting a webpage?

Answer»

The steps involved in hosting a webpage are: 

1. Selecting type of web hosting services 

2. Installation of web applications 

3. Domain registration 

4. Developing web content and 

5. Uploading HTML files

4.

SQL supports a set of logical operators. Name any one of them.

Answer»

AND, OR, NOT

5.

What is the extension with which a work book is saved?

Answer»

The extension file name with which a work book is saved is *.XLS

6.

What is E-commerce? Explain any two types.

Answer»

The e-commerce is defined as buying and selling of products or services over electronic systems such as the Internet and other computer networks

1. B2B - Business to business:

Electronic commerce that is conducted between business organizations is referred to as business-to-business or B2B. for example, transactions between manufacturing industry with suppliers of raw materials.

2. B2C - Business to Consumer:

Electronic commerce that is conducted between traders and consumers is referred to as business-to-consumer or B2C. This is the type of electronic commerce conducted by companies such as Amazon.com, ebay.com, etc.

7.

What is nested structure? Give example.

Answer»

A structure defined as a member of another structure is called nested structure.

Example of a nested structure: struct date

{

int day;

int month;

int year;

};

struct student

int regno;

char name[20];

char class[10];

struct date dob;

struct date admissiondate;

}

st1, st2, st3;

In the above example, st1, st2, and st3 are the structure variable of type student and date is a ‘ structure definition. The members of student structure are Regno, is a integer datatype, name and class which are char type and dob admission date are date structure type variable members. The dob and admission date are and the structure variable who are members of another structure. 

8.

Explain passing default argument to the function with an example. 

Answer»

When we define a function, we can specify a default value for each of the parameters. This value will be used if the corresponding argument is left blank during function call to the called function.

This is done by using the assignment operator and assigning values for the arguments in the function definition. During the function call, if a value for that parameter is not passed then default value is used, but if a value is mentioned then this default value is ignored and the passed value is used.

Consider the following example:

#include<iostream>

int sum (int a,int b = 20)

{

int result;

result = a + b;

return(result);

}

int main()

{

//local variable declaration:

int x = 100;

int t = 200;

int result;

//calling a function to add the values.

result = sum(x,y);

cout<<"Total value is :'<<result<<endl;

//calling a function again as follows.

result = sum(x);

cout<<"Total value is :'<<result<<endl;

return 0;

}

In the above program, the statement int sum(int a, int b=20) in the function header indicates the v default argument to the variable b is assigned with the value 20. During the first function call, the statement result = sum(x, y); copies the value of x and y to the called function and process of the result. 

During second time function call i.e., result = sum(x);, only one argument is mentioned and the value for second argument is obtained from the default argument which is mentioned in the function definition i.e., b=20 and gives the processed result.

9.

Write a C++ program to find the sum of all the rows and sum of all the columns in a matrix.

Answer»

#include<iostream.h>

#include<iomainip.h>

void main()

{

int a[5][5],rsize,csize,i,j,rsum,csum;

cout<<"Enter the order of matrix";

cin>>rsize>>csize;

cout<<"Enter the marix elements"<<endl;

for(i = 0;i<rsize;i++)

for(j = 0;j<csize;j++)

cin>>a[i][j];

for(i = 0;i<rsize;i++)

{

rsum = 0

for(j = 0;j<csize;j++)

rsum = rsum + a[i][j];

cout<<"The sum of "<<i + 1<<"row is"<<rsum<<endl;

}

for(i=0;i<csize;i++)

{

csum =0;

for(j=0;j<rsize;j++)

csum = csum + a[j][i];

cout<<"The sum of"<<i +1<<"column is"<<csum<<endl;

}

10.

Explain logical operators with example?

Answer»

The operators which perform combine or negate the expressions that contain relational operators, are called logical operators. 

Logical operators are used to combine one or more relational expressions.

The logical operators are:

1.  ! (NOT),

2.  || (OR),

3.  && (AND).

For example, if (age>18 && citizen =”Indian”)

11.

How do you initialize one dimensional array?

Answer»

Initialization of one dimensional array:

int marks[6] = {91, 96, 90, 94 ,99, 93};

12.

Explain the cascading of input and output operators?

Answer»

Cascading is a way to extract/insert multiple values from/into more than one variable using one cin/cout statement. Cascading of output operator (>>):

cout << “Value of B=” << b; Cascading of input operator (>>):

int n1, n2, n3;

13.

What is two-dimensional array? Write its syntax and example.

Answer»

Two dimensional array is a collection of elements of similar type that share a common name, structured in two dimensions. Each element is accessed by two index values.

Syntax:

<data-type> <array-name> [<sizel>] [<size2>];

Example:

int marks[5][5];

14.

Write the differences between1.  if statement2.  if-else statement with an example for each.

Answer»

Example:

#include <iostream.h>

void main()

{

int a = 100;

int b = 200;

If (b>a)

{

cout <<"B is greater than A";

}

}

Result:

B is greater than A

In the above example the condition in the if statement returns a true value so the text “B is greater than A” is displayed. If value of ‘a’ is greater than value of ‘b’ then no message is displayed.

Example:

#include <iostream.h>

void main()

{

int a = 10;

int b = 20;

If (a>b)

{

cout <<"A is greater than B";

}

else

{

cout<<"B is greater than A";

}

}

Result:

B is greater than A In the above example the “if condition is true then the message ‘A’ is greater than B” is displayed and in the above program, condition is false so the code in the “else” part is executed. 

15.

Write a program to check whether a given number is power of 2 using while statement.

Answer»

#include<iostream.h>

#include<iomainip.h>

void main()

{

int n,temp,flag = 1;

cout<<"Enter a number:";

cin>>n;

temp = n;

while(temp > 2)

{

If(temp % 2==1)

{

flag = 0;

break;

}

else

temp = temp/2;

}

If(flag = = 1)

cout<<n<<"is power of 2"<<endl;

else

cout<<n<<"is not power of 2"<<endl;

}

16.

What is the function of UPS? Mention different types of UPS.

Answer»

The function of UPS is

  • UPS unit give continuous power supply in the event of main source power break.
  • It also regulates the high and low voltage in power supply.
  • They give different backup power ranging from 15 minutes to several hours.

On-line UPS and Off-line UPS are the two types of UPS.

17.

Write a short note on internet.

Answer»

Internet is a worldwide network of computers connecting thousands and thousands of com¬puters across the globe. It is formed by the joining of many smaller networks around the world to form the largest network in the world.

In 1969 the American Department of Defense (DOD) started a network of devices called ARPANET (Advanced Research Projects Administration Network) with one computer in California and three in Utah. The actual term Internet was coined in 1995 by the FNC (Federal Networking Council, USA). 

The computers of the Internet are connected through telephone lines, satellite links, modem and through many other means.

Internet consists of the following applications:

  • World Wide Web # E-Mail # Chatting # Video Conferencing  
  • Searching for information # Online Shopping and Trade # 

Education and Research Uses of internet:

  • One can talk to anyone anywhere around the world.
  • Ocean of resources waiting to be mined.
  • One can do research on any subject for a project.
  • Online business, on-line reservations can be done sitting at home or workplace.
18.

Discuss the characteristics of a computer in detail, (any three)

Answer»

The main characteristics of a computer are:

Computers are fast in doing calculations. The speed of the computer is measured in terms of million instruction per second (MIPS).

1. Storage Capacity: Computers come with large amount of memory. They can hold lot of data. Computers can show a particular piece of information from large amount of data in a short time. 

2.  Diligence:  After doing work for sometime, humans become tired but computers do not become tired. They work continuously. In fact, some computers which control telephone exchanges are never stopped. This is called diligence.

3.  Accuracy: The results that the computers produce are accurate provided data and programs are reliable.

19.

Explain the General structure of C++ program with an example.

Answer»

#include <iostream>

//main() is where program execution begins.

int main()

{

cout <<"Hello world"; // prints Hello world

return 0;

}

The various parts of the above program:

  • headers, which contain information that is either necessary or useful to program. For this program, the header is needed.
  • The next line // main() is where program execution begins. is a single-line comment available in C++. Single-line comments begin with // and stop at the end of the line.
  • The line int main() is the main function where program execution begins.
  • The pair of { } indicates the body of the main function.
  • The next line cout<< “This is my first C++ program.”; causes the message “This is my first C++ program” to be displayed on the screen.
  • The next line return 0; terminates main( )function and causes it to return the value 0 to 1 the calling process.
20.

Write a C++ program to find the second largest out of the n numbers in the array.

Answer»

#include<iostream.h>

#include<iomainp.h>

void main()

{

int a[50],I,n,firstlarge,secondlarge;

cout<<"Enter the number of elements"<<end1;

cin>>n;

cout<<"Enter the elements now :"<<end1;

for(i = 0;i<n;I++)

cin>>a[1];

if (a[0]>a[1])

{

firstlarge = a[0];

secondlarge = a[1];

}

else

{

firstlarge = a[1];

secondlarge = a[0];

}

for(i=2;i<n;i++)

if(a[i]>firstlarge)

{

secondlarge = firstlarge;

firstlarge = a[i];

}

else if (a[i]>secondlarge)

secondlarge = a[i];

cout<<"The second largest number is"secondlarge<<endl

}

21.

List the different modes of opening a file with their meaning in C++.

Answer»

The methods of opening file within C++ program

  • Opening a file using constructor
  • Opening a file using member function open() of the class

Opening a file using constructor:

The syntax for opening file for output purpose only is ofstream obj(“filename”);
Example:
ofstream fout(“results.dat”);

22.

What is array of pointers? Give an example.

Answer»

The one dimensional or two-dimensional pointer array is called array of pointer.
For example, int *ptr[5];
Where *ptr is array pointer variable and size of array is 5. i.e., ptr[0], ptr[l], ptr[2], ptr[3], ptr[4].

23.

Write the features of I generation and II generation of computers. 

Answer»

1.  generation computers:

PeriodComponent usedAccess TimeCost
1949 - 1959Vacuum Tubein Milli secondsVery expensive

1.  The first computers used vacuum tubes for electronic circuitry and magnetic drums for memory. They were very expensive to operate and the power consumption was high, generated a lot of heat, which was often the cause of malfunctions.

2.  First generation computers were communicated through machine language to perform operations, and they could only solve one problem at a time.

3.  Input was based on punched cards and paper tape, and output was displayed on printouts.

2.  Second-generation computers:

PeriodComponent usedAccess TimeCost
1959 - 1965Transistorin Milli secondsLess than I gen. computers
 

1.  In the second generation computers, symbolic or assembly languages were used. High-level programming languages were also in use at this time, such as early versions of COBOL and FORTRAN. Their memory consisted of magnetic core technology.

2.  Second-generation computers still relied on punched cards for input and printouts for output.
24.

Explain the process of the creation of a structure in C++ with an example.

Answer»

struct  <structure-tag>

{

<data_type> <member variable 1>}list of members

<data_type> <member variable 2>} list of members

<data_type> <member variable 3>

} <structure-variable-name 1>,<structure-variable-name 2>;

is the reserved or keyword used in structure definition. : Is the name given by the programmer and used to identify the structure in future re-definitions. They are used to declare structure variables.

<data-type>: Any valid data type in ‘C’

< member variable 1…4>: are names of the variables.

<structure-variable-name 1...2>: It is used to access the members of the structure

Example:

struct student

{

int regno;

char name[20];

char class[5];

char combination[4];

float fees;

}st,st2,st3;

25.

Discuss on1.  BCD2.  EBCDIC3.  ASCII

Answer»

1. Binary Coded Decimal (BCD) code:

In this code each decimal digit is represented by a 4-bit binary number. BCD is a way to express each of the decimal digits with a binary code. In the BCD, with four bits we can represent sixteen numbers (0000 to 1111). But in BCD code only first ten of these are used (0000 to 1001). The remaining six code combinations i.e. 1010 to 1111 are invalid in BCD.

2.  EBCDIC:

EBCDIC (Extended Binary Coded Decimal Interchange Code is a binary code for alphabetic and numeric characters that IBM developed for its larger operating systems. In an EBCDIC file, each alphabetic or numeric character is represented with an 8-bit binary number. 256 possible characters (letters of the alphabet, numerals, and special characters) are defined.

3. ASCII code:  ASCII (American Standard Code for Information Interchange) is the most widely used coding system to represent data. ASCII is used on many personal computers and minicomputers. ASCII is a 7-bit code that permits 27 = 128 distinct characters. The 128 different combinations that can be represented in 7 bits are plenty to allow for all the letters, numbers and special symbols. An eight bit was added. This allowed extra 128 characters to be represented. The extra 128 combinations are used for symbols such as Ç, ü, è, ©, ®, Æ, etc.

26.

The function in the following circuit is:(a)  abcd(b)  ab + cd(c)  (a + b)(c + d)(d)  a + b + c + d(e)  (a’ + b’)+(c’ + d’)

Answer»

(e)  (a’ + b’)+(c’ + d’)

27.

The function in the following circuit is :(a)  x’ + y’ + z’(b)  x + y + z(c)  x’z’ + y’z’(d)  xy + z\(e)  z

Answer»

(c)   x’z’ + y’z’ 

28.

Write a program to find the sum of all the digits of a number using while statement.

Answer»

#include<iostream.h>

#include<iomainp.h>

void main()

{

int n,temp,sum = 0,reminder;

cout<<"Enter any positive whole number";

cin>>n;

temp = 1;

while(temp! = 0)

{

remainder = temp % 10;

sum = sum + reminder;

temp = temp/'0;

}

cout <<"The sum of digits of "<<n<<"is"<<sum<<endl;

}

29.

Write the applications of C++.

Answer»
  • It is a versatile language for handling very large programs
  • It is suitable for virtually any programming task including development of editors, compil-ers, databases, communication systems and any complex real life application systems
  • It allows us to create hierarchy-related objects, so we can build special object-oriented libraries which can be later used by many programmers
  • While C++ is able to map the real-world problem properly, the C part of C++ gives the language the ability to get close to the machine – level details
  • C++ programs are easily maintainable and expandable. 
30.

Classify any three types of operating system.

Answer»

The three types of operating systems are:

1.  Single user operating sytems:

Single user operating systems allows only one user to share the system resources including the CPU. For example, DOS (disk operating system).

2. Batch operating system:

In a batch processing operating system interaction between the user and processor is limited or there is no interaction at all during the execution of work. Data and programs that need to be processed are bundled and collected as a ‘batch’ and • executed together.

For example, IBM OS/2.

3. Multi tasking operating system:

In multi tasking operating system several applications maybe simultaneously loaded and used in the memory. While the processor handles only one application at a particular time and switch between the applications and simultaneously execute each application.

For example, Windows operating system.

4. Multi user operating system:

This multi user operating system allows multiple users to simultaneously use the system, the processor splits its resources and handles one user at a time.

For example, UNIX.

31.

Given F = A’B + (C’ + E)(D + F’), use de Morgan’s theorem to find F’.(a)  ACE’ + BCE’ + D’F(b)  (A + B’)(CE’ + D’F)(c)  A + B + CE’D’F(d)  ACE’ + AD’F + B’CE’ + B’CE’ + B’D’F(e)  NA

Answer»

A’B + (C’ + E)(D + F’)

= (A’B)’ + ((C’ + E)(D + F’))’ 

= (AB’) + (C’ + E)’(D + F’)’

= (AB’) + (C + E’)(D’ + F) 

= (A + B’)(CE’ + D’F)

So , F’ = (A + B’)(CE’ + D’F)

32.

Write a short note on structured programming.

Answer»

Structured Programming

The concept was contributed by Professor Dijkstra and other colleagues made it popular. Structured Programming deals only with logic and code and suggests making use of programming structures such as sequence, selection, iteration and modularity in programs.

Features:

1.  It focuses on techniques of developing good computer programs and problem solutions.

2.  The structures can be repeated within each other.

3.  It is most important to consider single-entry and single-exit control in programs and structures.

4.  Structured cod – is like a page, which can be read from the top to bottom without any backward references.

Advantages:

1.  Programs are easy to write because the programming logic is well organized.

2.  Programs can be functionally divided into smaller logical working units (modularity).

3.  Modularity helps to easily understand the program, test and debug.

4.  Easy to maintain because of single entry and single exit.

5. Eliminates the use of undisciplined controls (GO TO, BREAK, etc.,) in the program.

6.  Read from top to bottom makes the code easy to read, test, debug, and maintain.

33.

Mention various characteristics of object-oriented programming language.

Answer»

The characteristics of object-oriented programming are objects, classes, data abstraction, data encapsulation, inheritance, and polymorphism.

34.

Explain the Codd’s rules for database management.

Answer»

Dr. Edgar Frank Codd was a computer scientist while working for IBM he invented the relational model for database management. Codd proposed thirteen rules (numbered zero to twelve) and said that if a Database Management System meets these rules, it can be called as a Relational Database Management System. These rules are called as Codd’s 12 rules.
Rule Zero:

  • The system must qualify as relational, as a database, and as a management system.

The other 12 rules derive from this rule. The rules are as follows :

Rule 1:
The information rule:

All information in the database is to be represented in one and only one way, namely by values in column positions within rows of tables.

Rule 2:
The guaranteed access rule:

All data must be accessible. This rule is essentially a restatement of the fundamental requirement for primary keys. It says that every individual value in the database must be logically addressable by specifying table name, column name and the primary key value of the row.

Rule 3:
Systematic treatment of null values:

The DBMS must allow each field to remain null (or empty). The NULL can be represented as “missing information and inapplicable information” that is systematic, distinct from all regular values, and independent of data type. Such values must be manipulated by the DBMS in a systematic way.

Rule 4:
Active online catalog based on the relational model:

The system must support an online, inline, relational catalog that is accessible to authorized users by means of their regular query language

Rule 5:
The comprehensive data sublanguage rule:

The system must support at least one relational language that

  1. Has a linear syntax
  2. Can be used both interactively and within application programs,
  3. Supports data definition operations, data manipulation operations, security and integrity constraints, and transaction management operations.

Rule 6:
The view updating rule:

All views that can be updated theoretically, must be updated by the system.

Rule 7:
High-level insert, update, and delete:

This rule states that insert, update, and delete operations should be supported for any retrievable set rather than just for a single row in a single table.

Rule 8:
Physical data independence:

Changes to the physical level (how the data is stored, whether in arrays or linked lists etc.) must not require a change to an application based on the structure.

Rule 9:
Logical data independence:

Changes to the logical level (tables, columns, rows, and so on) must not require a change to an application based on the structure.

Rule 10:
Integrity independence:

Integrity constraints must be specified separately from application programs and stored in the catalog. It must be possible to change such constraints as and when appropriate without unnecessarily affecting existing applications.

Rule 11:
Distribution independence:
The distribution of portions of the database to various locations should be invisible to users of the database. Existing applications should continue to operate successfully.

Rule 12:
The non subversion rule:
If the system provides a low-level (record-at-a-time) interface, then that interface cannot be used to subvert the system, for example, bypassing a relational security or integrity constraint

35.

Explain switch-case statement with a suitable program example. 

Answer»

Switch statement compares the value of an expression against a list of integers or character constants. The list of constants is listed using the “case” statement along with a “break” statement to end the execution.

#include<iostream.h>

int main(void)

{

int day;

cout<<"Enter the day of the week between 1-7::";

cin>>day;

switch(day)

{

case 1:

cout<<"Monday";

break;

case 2:

cout<<"Tuesday";

break;

case 3:

cout<<"Wednesday";

break;

case 4:

cout <<"Thursday";

break;

case 5:

cout <<"Friday";

break;

case 6:

cout <<"Saturday";

break;

default:

cout<<"Sunday";

break;

}

}

Result:

Enter the day of the week between 1-7::7

Sunday

In the above Control Structure example, the “switch” statement is used to find the day of the week from the integer input got from the user. The value present in the day is compared for equality with constants written in the word case. Since no equality is achieved in the above example (from 1 to 6) as the entered value is 7, default value is selected and gives “Sunday” as the result. 

36.

What are the types of inheritance? Explain any two.

Answer»

The different type of inheritances is Single inheritance, Multiple Inheritance, Hierarchical Inheritance, Multi-level inheritance, and Hybrid inheritance.
1. Single inheritance:
A derived class with only one base class is called single inheritance. For example, If A is base class then class 6 derive from base class A.

2. Multilevel inheritance:
A class can be derived from another derived class which is known as multilevel inheritance. For example, The derived class C inherit B class whereas B is derived from class A.

37.

Write a note on BCD and Excess-3 code.

Answer»

1.  Binary Coded Decimal (BCD) code:

In this code, each decimal digit is represented by a 4- bit binary number. BCD is a way to express each of the decimal digits with a binary code. In the BCD, with four bits we can represent sixteen numbers (0000 to 1111). But in BCD code only first ten of these are used (0000 to 1001). The remaining six code combinations i.e. 1010 to 1111 are invalid in BCD.

2.  Excess-3 code:

The Excess-3 code is also called an XS-3 code. It is a nonweighted code used to express decimal numbers. The Excess-3 codewords are derived from the 8421 BCD code words adding (0011)2 or (3)10 to each codeword in 8421.

The excess-3 codes are obtained as follows:

Decimal Number—— >8421 BCD—> Excess – 3 

38.

Mention the three characteristics of C++ programming language.

Answer»

Object oriented programming, bottom-up program execution and portability are the three characteristics of c ++.

39.

Explain the structure of a C++ program with an example. 

Answer»

# include <iostream>

// main() is where program execution begins.

int main ()

{

cout <<"Hello World";// prints Hello World

return 0;

}

The various parts of the above program: 

  • headers, which contain information that is either necessary or useful to program. For this program, the header is needed.
  • The next line // main() is where the program execution begins. It is a single-line comment available in C++. Singleline comments begin with // and stop at the end of the line.
  • The line int main() is the main function where the program execution begins.
  • The pair of {} indicates the body of the main function.
  • The next line cout>> “This is my first C++ program.”; causes the message “This is my first C++ program” to be displayed on the screen.
  • The next line return 0; terminates main( )function and causes it to return the value 0 to ‘ the calling process.
40.

Explain the role of computers in the education field.

Answer»

1.  Students use computers for simple word processing that is, to type reports and other documents and to print out the results. This application allows students to revise and edit easily. A computer makes it much easier to redraft a sentence and produce a new printout when compared with producing a handwritten copy.

2.  Encyclopedias and other reference works are available on CDROMs, which can be searched by the students using the computer in their classrooms or school libraries.

3.  Computer-aided instruction (CAI). Interactive programs provide practice in such basic skills as spelling, math computation, and word recognition.

4. The Internet and World Wide Web is a source of information resource, that students may want to access, using their computer at school or home.

5.  Computers are used in running school and college administrations, during the admission procedures, storing of official arid student records. They are also used in syllabus planning and decision-making, controlling.

6.  Computers are helpful in directing aptitude tests and achievement tests, at the time of entrance exams. They also process records of salaries, examinations, schemes of examination, printing of papers and question papers, evaluation of answer sheets, mark sheets, and certificates.

41.

Explain cascading of i/o operations

Answer»

The multiple use of input or output operators in a single statement is called cascading of i/o operators. 

Eg: To fake three numbers by using one statement is as follows cin>>x>>y>>z;

 To print three numbers by using one statement is as follows 

cout<<x<<y<<z;

42.

Define Arrays and classify various types of arrays.

Answer»

Array is a group of similar elements that share a common name. 

There are three types of arrays.

1. One dimensional array

2. Two dimensional array

3. Multi dimensional array

43.

What is typecast? Mention the types of typecasting.

Answer»

Typecasting is making a variable of one type, such as an int, act like another type, a char, for one single operation. The two types of typecasting are implicit conversion and explicit conversion. 

44.

Write a note on character set and tokens. Give example.

Answer»

Character set is a set of valid characters that a language can recognize.

• Letters A-Z,

• Digits 0-9

• Special characters + - */A\()[]{}=!=o'@

Tokens:  A token is a group of characters that logically belong together. C++ uses the following types of tokens. Keywords, Identifiers, Literals, Punctuators, and Operators.

45.

Explain the structure of C++ program. Give example? 

Answer»

#include<iostream>

//main() is where program execution begins.

int main()

{

count<<"Hello World";>> //   prints Hello world

return 0;

}

The various parts of the above program:

  • Headers, which contain information that is either necessary or useful to program. For this program, the header is needed.
  • The next line // main() is where program execution begins, is a single-line comment available in C++. Single-line comments begin with // and stop at the end of the line.
  • The line int main() is the main function where program execution begins.
  • The pair of { } indicate the body of the main function.
  • The next line cout << “Hello world.”; causes the message “Hello world” to be displayed on the screen.
  • The next line return 0; terminates the main () function and causes it to return the value 0 to the calling process. 
46.

What is cascading in I/O operations? How is cascading useful in output operations?

Answer»

Cascading is a way to extract/insert multiple values from/into more than one variable using one cin/cout statement. Cascading allows the user to use cout one time but use << operator several times, to output many values.

47.

How is array of structures declared? Give an example. 

Answer»

The array of structure is a collection of array elements in which each element is a structure in the array.

struct student

{

int regno;

char name[50];

char class[6];

}s[100];

48.

Explain the characteristics of algorithm.

Answer»

The characteristics of algorithm are:

1.  It must be simple.

2.  Every step should perform a single task.

3.  There should not be any confusion at any stage.

4.  It must involve a finite number of instructions.

5.  It should produce at least one output.

6.  It must give a unique solution to the problem.

7.  The algorithm must terminate and must not enter to infinity.

49.

Explain ‘while’ structure with an example?

Answer»

A ‘while’ loop statement repeatedly executes a statement or sequence of statements written in the flower brackets as long as a given condition returns the value ‘true’.

Syntax: 

The syntax of a while loop in C++ is:

while(condition)

{

statement(s);

}

Here the condition may be any expression, and true for any non zero value. The loop iterates while the condition is true. When the condition becomes false, program control passes to the line immediately following the loop.

During the first attempt, when the condition is tested and the result is false, the loop body will be skipped and the first statement after the while loop will be executed.

Example: 

#include<iostream>

int main ()

{

int a = 10;

while(a<15)

{

cout<<<"value of a:"<<a<<endl;

a++;

}

return 0;

}

When the above code is executed, it produces the following results:

value of a: 10

value of a: 11

value of a: 12

value of a: 13

value of a: 14

50.

Give explanation of declaration of one-dimensional array with an example.

Answer»

int marks[6];

Name of the array is marks.

Type of the array is integer.

Size of the array is 6. i.e., we can store up to 6 integer values in the array.