Explore topic-wise InterviewSolutions in .

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

1.

What do you mean by subscript?

Answer»

To gain access to a single element within the array, a subscript is used. A subscript may be a numeric constant or an integer-valued variable, is enclosed in parentheses which identify the position of a given element in the array. For example, the first element of array TEST (containing the value 15) is referred to as TEST(0J. The second test score is as TEST[1], the third test score is as TEST[2], and so on. Therefore, the following statements are true:

TEST[0] = 15
TEST[1] = 25
TEST[2] = 5
TEST[3] = 81
TEST[4] = 75
Here, 0, 1, 2, 3 and 4 within parentheses are known as a subscript.

Subscripts are numbers that come after a symbol and below. 

For your reference: A3, Betc.

2.

(a) Explain the following with reference to ‘C’ language:(i) Data Type(ii) Variables.(b) What are the various arithmetic operators available in ‘C’ language? Explain with example.

Answer»

(a) (i) Data Type: A data type decides the amount of memory to be allocated to a variable to store a particular type of data. To allocate memory for a particular piece of data, we have to declare a variable of a particular data type. The variable declaration means that some memory is allocated and that portion of memory will be referred to by the variable name.
Data types, which are commonly used in programming tools can be classified as :

  • Numeric: Stores numeric value.
  • Alpha Numeric: Stores descriptive information.
  • A numeric data type is called int: Similarly, an alpha-numeric data type is named char in C.

(ii) Variables: A variable is a name that represents a number or a string. Each numeric variable must consist of a letter or a letter followed by an integer. All variables that are to be used in the program must be declared prior to its use. Declaring a variable means defining a name and a data type of a variable. Every variable declaration is terminated by a semicolon. Variable names must begin with an alphabet. The first character may be followed by a sequence of letters or digits and can also include the special character ‘Underscore’.

(b) Arithmetical Operators: Operators that perform mathematical operations are called Arithmetical operators. These operators form a mathematical expression using operands along- with. There are five types of arithmetical operands available in C++ which are as follows:

(i) Add (+): To perform addition of operands. These operands can either be literal, identifier or combination of both.
e.g.:
a + b
2 + 2
x + 2

(ii) Subtract (-): In order to perform subtraction, operands can be literal, identifier or combination of both.
e.g.:
x – y
15 – 5
A – 10

(iii) Multiply (*): This operator performs multiplication on operands.
e.g.:
y * z
15 * 32
A * 25

(iv) Divide (/): It is used to perform division of the two operands.
e.g.
A/B
25/5
X/2

(v) Exponentiation (%): It is a modulus operator and returns the remainder of the division. A / operator returns the quotient after the division of operands and a modulus operator returns the remainder after division.
e.g.
10 % 3
X % 2

3.

WAP to sort the elements of an array in ascending order.

Answer»

#include<stdio.h>
void main()
{
int A[100];
int n, i, j, temp;
printf (“Enter how many nos”);
scant (“%d”, &n);
for (i = 0; i < n; i++)
{
scanf (“%d”, &A[i]);
}
for (i =0; i < n - 1; i++)
{
for (j = 0; j < n + i; j++)
{
if (A [j +1] < A[j])
temp = A[j];
A[j] =A[j + 1];
A[j + 1] = temp;
}}
for (i = 0; i < n; i++)
{
printf (“%d”, A[i]);
}
}

4.

WAP to find the factorial of ‘n’.

Answer»

#include<stdio.h>
void main()
{
int n, i, fact = 1;
printf (“Enter the value for n”);
scanf (“%d”, &n);
for (i = 1; i <= n; i++)
{
fact = fact * i;
}
printf (“factorial of %d is %d”, n, fact);
}