Special Offer - Enroll Now and Get 2 Course at ₹25000/- Only Explore Now!

All Courses
C and C++ Interview Questions and Answers

C and C++ Interview Questions and Answers

January 28th, 2019

C and C++ Interview Questions and Answers

In case you’re searching for C and C++ Interview Questions and answers for Experienced or Freshers, you are at the correct place. Here you can find the most commonly posted basic C and advanced C++ Interview Questions with solutions and examples, which is applicable for beginner level as well as experienced level candidates. This detailed questionnaire will be a bookmark for anyone who is ready to prepare for C and C++ interview. The content covered by our experts in our center is the structure of C and C++, concepts of comments, OOPS, inheritance, Overloading, operators, exception handling, block scope, token, container, arguments, the syntax of C and C++, and many more to go on. You will be a master in completing your study on this list of questions and excel in professional roles like C/C++ Programmers, C++ Developer, Full Stack C++ Developer, C++ Software Engineer and Principal Engineer for C++. GangBoard offers Advanced C and C++ Interview Questions and answers that assist you in splitting your C and C++ interview and procure dream vocation as C and C++ Developer.

Q1) What is C++?

Answer: C++ is a programming language that is a superset of the C Language. C++ supports Classes which is not present in C. Unlike C, C++ is an object-oriented programming language supporting OOPS concepts like Polymorphism, Inheritance, etc.,

Q2) List out the differences between C and C++

Answer:

S.No. C C ++
1. Procedure Oriented Programming Object Oriented Programming
2. No Exception handling Provides Exception Handling
3. No References Supports References.
4. No OOPS Concept. Provides OOPS concepts like Inheritance, Polymorphism etc.,

Q3) What are the differences between Pointer and Reference?

Answer:

S.No. Pointer Reference
1. It is an alias for another variable. It stores the address of a variable.
2. Must be initialized when declared. Initialization is not mandatory while declaration of a pointer.
3. Cannot be assigned to NULL value. Pointer can be assigned to NULL value.
4. Cannot be made to change the value once the reference is assigned. Pointer can be made to point to different address or simply reassigned.
5. Does not require * operator to access the value. Requires * operator to access the value stored in the address which it points to.

Q4) Name the OOPS concepts available in C++?

Answer:

  • Polymorphism
  • Inheritance
  • Encapsulation
  • Abstraction
  • Data Binding

Q5) What is a Class?

Answer:
A class is basically a user defined custom data type which is like a blue print that show cases the characteristics and behavior. For example, let’s take a bird. The characteristic of a bird are feathers, beak etc., The behavior or Features of a bird are Flying, eating etc., There are different variety of birds. So we can define a Class named bird and using this class’s characteristics and behavior we can declare different types of birds.

Q6) What is an object?

Answer:
Objects are instances of the class through which one can access the member variables and member functions. For example, consider the following class:

Class Bird
{
 char name [50];
};
Bird B1;
Here, B1 is an object of the class Bird. Through object B1, we can access the data member name and assign values. Similarly, we can create multiple objects for a class.

Q7) What is Inheritance?

Answer: Inheritance is the concept of reusing existing functionality by inheriting from it. By this way we eliminate redundancy of code. For example, we inherit some the genes from our father or grandfather. Similarly one can inherit an existing class to derive a new class. The exiting class is the base class while the inherited class will be derived class.

Q8) What is Polymorphism?

Answer: Polymorphism is the concepts of having one functionality do multiple things. The words “poly”(many) and “morph” (forms) is itself explain the concept.

Q9) What are the types of Polymorphism?

Answer:  Polymorphism is classified into two types namely:

  • Compile-time Polymorphism or Overloading
  • Run-time Polymorphism or Overriding

Q10) What is Encapsulation?

Answer: Encapsulation is the process of combining the data members and member functions together into a single unit so that outside members cannot access the data. Suppose a class contains private data members the only the member function of the class can access the data members.

Q11) What is Abstraction?

Answer: Abstraction is the process of revealing only vital elements without showing the actual implementation. Suppose a class contains public members then these public members can be accessed from outside the class too. But if these members were private then they cannot be accessed outside the class.

Q12) What are Storage Classes?

Answer: Storage class are nothing, but which determines the lifetime or scope of variables and functions. The different types of storage classes available in C++ are:

  1. Auto
  2. Static

Extern

  1. Register
  2. Mutable

Q13) When register storage class should be used?

Answer: Memory access in CPU register is speedy and the look-up execution time is way more efficient than normal memory in stack. So, when a variable is being used regularly or frequently then it can be declared as a register storage class.

Q14) What are access specifiers in C++?

Answer: Access specifiers are the keywords that determines the availability of the data members/member functions of a class outside.  The three access specifiers available in C++ are:

  • Public: Data members and Member functions declared under public specification can be accessed from outside the class.
  • Private: Data members and Member functions declared under private specification can be accessed only within the class and cannot be accessed from outside the class even by derived class objects.
  • Protected: Data members and Member functions declared under protected specification can be accessed by its own class and the derived classes.

Q15) What is constructor?

Answer: A constructor is a special member function of a class that initializes the class object. The compiler provides a default constructor if the user has not provided a constructor. The constructor function name should be declared as the same name of Class. For example:

Class Bird
{
                char name [50];
   public:
                Bird ()
{
       printf(“\nThis is Default Constructor of Class Bird\n”)
}
};
There are basically three types of constructor available namely:

  • Default Constructor
  • Parameterized Constructor
  • Copy Constructor

Q16) What is destructor?

Answer: A destructor is a special member function of a class that destroys the resources that have been allocated to the class object. The destructor class name is same as that of the class but prefixed with a ~ symbol.
For example:

Class Bird
{                char name [50];
   public:
                ~Bird ()
{
       printf(“\nThis is Destructor of Class Bird\n”)
}
};

Q17) Explain Virtual Destructor

Answer: A virtual destructor does the same function as that of a normal destructor but along with the destruction of derived class objects too. The virtual keyword must be employed before the function name as shown:
virtual ~Bird()

Q18) What is copy constructor?

Answer: A copy constructor is one of the types of constructor that is used for initializing a class object with the help of another object. It takes the same name as that of the class with one const class reference object as argument For example:

Class Bird
{
char name [50];
public:
Bird (const class &B)
{
name = B.name;
}
};

Q19) Explain Function Overloading

Answer: Function overloading as the name suggest, overloading a function to give different functionality. The function name will be same, but it must differ in either of the following conditions:

  1. Differ in Number of Arguments and\or
  2. Differ in the type of Input Arguments

Example:

#include <iostream>
using namespace std;
void Show (int i) {
  cout << " Here is int " << i << endl;
}
void Show (double  f) {
  cout << " Here is float " << f << endl;
}
void Show (char* c) {
  cout << " Here is char* " << c << endl;
}
int main() {
  Show (10);
  Show (10.10);
  Show ("ten");
  return 0;
}

Q20) Can a constructor be overloaded?

Answer: Yes, but only through number of input arguments. Example – Default and parameterized constructors.

Q21) Can a destructor be overloaded?

Answer: No. A destructor must simply destroy all the resources allocated for the object.

Q22) Explain Function Overriding

Answer: Function Overriding is a run time polymorphism which allows derived class to provide its own implementation of the base class member functions. The newly implemented function in derived class is called Overridden Function.
Example:

class Base
{
public:
    void display ()
    { cout<< "Base Class Display" <<endl; }
}; 
class Derived: public Base
{
public:
    void display ()
    { cout<< "Derived Class Display" <<endl; }
};

Q23) What are Virtual Functions?

Answer: Virtual functions are base class member functions which helps to resolve function calls when there is redefinition for the same function provided by the derived class. Some of the important points to be remembered:

  • Virtual functions of the base class can be redefined in the derived class.
  • Provided virtual function in base class, when there is a base class pointer pointing to derived class object, the invoke of the function will call the derived class implementation.
  • Virtual is just a keyword used to help C++ deiced at run-time which method has to be called depending on the type of the object pointed by base class pointer.

Example:

#include<iostream>
using namespace std;
class Base
{
public:
    void F_1() { cout << "Base F-1\n"; }
    virtual void F_2() { cout << " Base F-2\n"; }
    virtual void F_3() { cout << " Base F-3\n"; }
    virtual void F_4() { cout << " Base F-1\n"; }
};
class Derived : public Base
{
public:
    void F_1() { cout << "Derived F-1\n"; }
    void F_2() { cout << "Derived F-2\n"; }
    void F_4(int x) { cout << "Derived F-4\n"; }
};
int main()
{
    Base *P;
    Derived D1;
    P = &D1;
     // Early binding because F_1() is non-virtual in base
    P->F_1();
     // Late binding
    P->F_2();
    // Late binding (
    P->F_3();
    // Late binding
    P->F_4();
  }
Output:
Base F-1
Derived F-2
Base F-3
Base F-4
Here base class pointer points to derived class object. Function F_1() was not virtual and it invoked base class function whereas Function F_2() was virtual and hence it invoked derived class method.

Q24) What is pure virtual function?

Answer: Pure virtual function is a type of virtual function which has only declaration and not definition. A pure virtual function declaration is assigned with zero. All deriving class must implement the pure virtual function.
virtual Display() = 0;

Q25) What is an Abstract Class?

Answer: A class is said to be abstract when it contains at least one pure virtual function. Instantiation is not allowed for an abstract class. And the deriving class must implement or provide definition for the pure virtual functions.
Example:
class Base { public:     virtual void display () = 0; };

Q26) What is the use of pure virtual function?

Answer: A pure virtual function does not have implementation in base class. This will be useful during scenarios where no actual implementation is required in the base class context. For example let’s say we have a base class named Shape which is having a function “DrawShape()” as pure virtual. In base class there is actually no need to give a definition. Now, when a Class Square derives from Class Shape, it provides an actual definition for DrawShape() as drawing a square.

Q27) Can Constructors be virtual?

Answer: In order to create an object, we need to know the complete information about it or the exact type of what we want to create. Hence, a constructor cannot be virtual.

Q28) Can Destructors be declared as pure virtual function?

Answer: Yes, but we must define the destructor anyways.

Q29) What is virtual class?

Answer: A virtual class resolves the ambiguity caused due to multilevel inheritance. Suppose two Classes B and C derives from a Base Class A. And another derived Class D derives from Classes B and C. Now when we create an object for Class D, it will have multiple copies of Base Class B. But if the Base Class A is derived as virtual by Classes B and C, this will be prevented.
Example:

Class A
{ … };
Class B: virtual public A
{ … };
Class C: virtual public A
{ … };
Class D: public B, public C
{ … };

Q30) What are the different types of inheritance?

Answer:

  • Multiple: (Class A, B) -> Class C
  • Multi-Level: Class A -> Class B -> Class C
  • Hierarchical: Class A -> (Class B, C) -> Class D

Q31) What are new and delete operator?

Answer: The new operator is used to dynamically allocate memory and delete operator is used to destroy the memory allocated by the new operator.

Q32) What are Friend Functions?

Answer: Friend functions are special member functions of a class which can access the data members and member functions from outside the class without using the Class object.

Example:
#include <iostream>
using namespace std;
class Length
{
    private:
        int value;
    public:
        Length () {  value = 0; }
        friend int addExtra(Distance); //friend function
};
int addFive(Length l) // friend function definition
{   
 //accessing private data from non-member function
    l.value += 5;
    return l.value;
}
int main()
{
    Length L;
    cout<<"Length: "<< addExtra(L);
    return 0;
}

Q33) What is a Friend class?

Answer: Similar to friend function one class can be made as a friend to another class. Let’s say X and Y are separate classes. When X is made friend to class Y, the member functions of Class X becomes friend functions to Class Y. Member functions of Class X can access the private and protected data of Class Y but Class Y cannot access the same of ClassX.

class X;
class Y
{
   // class X is a friend class of class Y
   friend class X;
   ... .. ...
}
class X
{
   ... .. ...
}

Q34) What is a scope resolution operator?

Answer: A scope resolution operator :: is used for defining the member functions of a class outside its class. It is also used for resolving the scope of the global variables.

class Line {
   public:
      Line();  // This is the constructor
   private:
      double length;
};
// Member functions definitions including constructor
Line::Line() {
   cout << "Object is being created" << endl;
   length = 0;
}

Q35) What are actual and formal parameters?

Answer: Actual parameters are variables or arguments that are being passed to the function during a function call.
Formal parameters are the variables or arguments that are being received in the functions.

Q36) Explain Call by Value?

Answer: Call by Value method passes only the values of the actual parameters to the formal parameters. So, two different copies are made. Any change made to the formal parameters will not affect the actual parameters.
Example:

#include <iostream>
using namespace std;
// function declaration
void Exchange(int A, int B) {
   int temp;
   temp = A;
   A = B;   
   B = temp;
}
int main () {
   int X = 100, Y = 200;
   cout << "Before Exchange, value of X :" << X << endl;
   cout << "Before Exchange, value of Y :" << Y << endl;
   Exchange (X, Y);
   cout << "After Exchange, value of X :" << X << endl;
   cout << "After Exchange, value of Y :" << Y << endl;
    return 0;
}
Output:
Before Exchange, value of X :100
Before Exchange, value of Y :200
After Exchange, value of X :100
After Exchange, value of Y :200

Q37) Explain Call by Address?

Answer: In Call by Address, the address of the actual parameters are passed to the formal parameters which are pointer variables. Hence, any change made to the formal parameters are reflected in the actual parameters too.
Example:

#include <iostream>
using namespace std;
// function declaration
void Exchange(int *A, int *B) {
   int temp;
   temp = *A;
   *A = *B; 
   *B = temp;
}
int main () {
   int X = 100, Y = 200;
   cout << "Before Exchange, value of X :" << X << endl;
   cout << "Before Exchange, value of Y :" << Y << endl;
   Exchange (&X, &Y);
   cout << "After Exchange, value of X :" << X << endl;
   cout << "After Exchange, value of Y :" << Y << endl;
    return 0;
}
Output:
Before Exchange, value of X :100
Before Exchange, value of Y :200
After Exchange, value of X :200
After Exchange, value of Y :100

Q38) Explain Call by Reference?

Answer: In Call by reference the formal parameters are reference variables and so both the actual and formal parameters point to the same memory locations. Hence, any changes made to the formal parameters will reflect in the actual parameters too.
Example:

#include <iostream>
using namespace std;
 // function declaration
void Exchange(int &A, int &B) {
   int temp;
   temp = *A;
   *A = *B;
   *B = temp;
}
 int main () {
   int X = 100, Y = 200;
   cout << "Before Exchange, value of X :" << X << endl;
   cout << "Before Exchange, value of Y :" << Y << endl;
   Exchange (X, Y);
   cout << "After Exchange, value of X :" << X << endl;
   cout << "After Exchange, value of Y :" << Y << endl;
   return 0;
}
Output:
Before Exchange, value of X :100
Before Exchange, value of Y :200
After Exchange, value of X :200
After Exchange, value of Y :100

Q39) Explain command line arguments?

Answer: Main() is the entry point of a C++ program and it behaves like a function. It takes arguments like any other functions except that it cannot be invoked from within the program. Here, command line arguments come into picture. The arguments passed through the command line are received by the main function as input arguments.
Example:

int main( int ARGC, char *ARGV[]) {
}
Here,ARGC – Count of  number of arguments passed through the command line.
ARGV – Is the vector or array containing the values of the arguments
ARGC[0] – is the program name.
Suppose
$ ./a.out 25 35
ARGC = 3
ARGV [0] = a.out
ARGV [1] = 25
ARGV [2] = 35  

Q40) Explain about Recursive Functions?

Answer: Recursive functions are functions which call itself. The functionality of recursive functions are similar to loops – repeats the same logic again and again. Important points to consider for recursive functions:

  1. Function Call from within the function
  2. Proper exit condition/break point in the logic.

Example:

#include<iostream>
using namespace std;
void print (int num)
{
cout<<”\n”<<num;
if (num == 5)
 {
return;
}
else
{
 num++;
print(num);
}
}
int main()
{               
 print(1);               
 return 0;
}

Q41) What is stack overflow and when does it occur?

Answer: A stack overflow denotes that the stack memory is filled and memory can be stored further in the Stack. A stack overflow occurs when a recursive function keeps on executing without any exit condition or break point. For each and every recursive call, a new function call address will be written into the stack memory thus leading to stack overflow when there is no proper exit condition.

Q42) What is shallow copy and deep copy?

Answer: Shallow copy performs bit-by-bit memory dump from one object to another whereas Deep copy performs field by field memory dump. Copy Constructor and overloaded assignment operator are examples of deep copy.

Q43) How does a normal object and a pointer object access members of a class?

Answer: Normal object access class members using . dot operator.
Pointer objects access class members using -> arrow operator.

Q44) What are the different types of initialization available in C++?

Answer:

  • Traditional C Way: int num = 10;
  • Constructor notation: int num(10);

Q45) What are exit and abort functions?

Answer: An exit call invokes the destructor of all constructed objects and then does a graceful termination from the program.
An abort call abruptly ends the program and dumps core memory. It does not call any destructor.

Q46) Compare C Struct and C++ Struct?

Answer:

S.No C Struct C++ Struct
1. Cannot have functions. Can have member functions.
2. Cannot have static members. Can have static members.
3. Struct keyword is necessary while declaring structure type variables. Do not require any keyword for declaring structure type variables.
4. Size of empty structure is undefined. Size of empty structure is 1.

Q47) What is an interface?

Answer: An interface is class which contains only pure virtual functions. It just provides a group of functions without any definition that must be overridden by the implemented classes. If all the functions in an abstract class are pure virtual then it becomes an interface.

Bird (const class &B)
{
name = B.name;
}
};

Q48) What does delete[] do?

Answer: The delete[] operator deletes the array of dynamically allocated memory allocated by the new[] operator.  

Q49) library function which is used to convert string value into value?

Answer: A toi()the function is used in header file is stdio.h

Q50) can we call any clam member function without using object of the class?

Answer: Yes,with static keyword

Q51) lose of scope resolution operator?

Answer: To define member function outside the class

Q52) list the operators which can’t be overloaded?

Answer: a.:: b.size of c.?: 4..

Q53) what is polymorphism?

Answer: We can use same name function with different purposes.

Q54) Which operator can change the program statement?

Answer: Conditional operator (? 🙂

Q55) What is the role of compression class in C ++?

Answer: Abstract class minimum is a pure virtual function.

Q56) What is Namespace?

Answer: Namespace is a set of different classes

Q57) What is the delay?

Answer: A virtual method (polymorphism)
A run time is determined by the late binding

Q58) What to do to get out?

Answer: The output () function is used to exit the program and return to the operating system.

Q59) Digid Class which can be viewed by the basic class data members?

Answer: In the public and protected section

Q60) What kind of function is not an independent function of a class, but what are the earlier methods of class?

Answer: Friend function

Q61) Who is the instrument for constructing the process of using another object of the same class?

Answer: Copy the constructor

Q62) Can several constructor be in a class?

Answer: Two

Q63) What does the following statement mean? Int (* ptr) [10];

Answer: Ptr represents 10 full numbers

Q64) How many default developers can be in a class?

Answer: This means that only one class has 1 default constructor.

Q65) What Is Default Configurator?

Answer: A null argument is a constructor or a buyer, where all the arguments have the default values, called the default constructor.

Q66) What is Class?

Answer: Class is a blue axis, which represents elements and processes. One class defined by a class is defined by a user defined web page type.

Q67) What is abstract class in C ++?

Answer: The class with at least 1 pure virtual function is called abstract class. We can not do a compression class immediately.

Q68) What is the reference to the variable in C ++?

Answer: An alternate variable is already an alternative name for the variable. The variable name and reference for the same location indicate the two points. Each process of the original variable can be achieved using the reference variable

Q69) Do you want to throw a strong organ function?

Answer: A standard element function can be implemented by the name of the class before it reaches the end of class objects. It can only update the standard members of the class.

A70) What are the operators / operators used to implement class members?

Answer: Point (.) & Arrow (->)

Q71) What are the data types to store the Boolean value?

Answer: bool, some oldest data type introduced in the C ++ programming language.

Q72) What is Function Overloading?

Answer: Parameters Define multiple functions of the same name with the individual list is called function overloading.

Q73) Do we have the String primitive data type in C++?

Answer: Null, it’s the class from STL (Standard template library).

Q74) Which process specifier/s can help to achive data hiding in C++?

Answer: Private and Protected.

Q75) What is the difference between Exit and Breakdown?

Answer: A smooth process of exit ends, which calls for destruction of all the constructed objects, and they are not called.

Q76) Can you call the Testriter openly?

Answer: Yes, but you only want to do this when you use new jobs.

Q77) Should virtual inheritance be used in a phase?

Answer: If there is a diamond class sequence, we have to use the virtual property below the diamond.

Q78) Explain the purpose of the resolution operator?

Answer: Allows a program to mark the identifier in a global view, which is hidden by another identifier of the same name in the local area.

Q79) Divergence and Reconciliation How do the exceptions differ using the Setzmp and Logjap?

Answer: Throwing action automatically generates products automatically from the entry point for the test.

Q80) What is a transformative builder?

Answer: An analyst who accepts a different type of argument.

Q81) What is the difference between a copyrunner and an overloaded assignment?

Answer: The argument creates a new object using the content of the object. An overloaded assignment operator delivers the contents of the existing material to another object of the same class.

Q82) What is a Virtual Destroyer?

Answer: The simple answer is one that is virtualized with a virtual destroyer virtual character.

Q83) When is a site better solution than a base class?

Answer: When designing a common class to control other types of goods or to design a different class, the design and behavior of those other forms are important for their control or management, especially when the other types are unknown (thus, common) container or manager class designer.

Q84) What is a stable member?

Answer: The function of the class or the function of the function of the class can be edited by the class itself.

Q85) What is an opener architect?

Answer: A replacement keeper declared open words. Compiler does not use an external constructor to implement changes of a particular kind. This is explicitly reserved for the purpose.

Q86) What is the standard template library?

Answer: A library of container templates approved by the ANSI team to include a standard C ++ specification.
The general program model, operating systems, quotations, algorithms, and such, STL is higher than the average of new technology for C ++ programming.

Q89) Explain the Run Time Type Identity?

Answer: The ability to determine the type of object of an object by using a directory operator or dynamic_ socket operator.

Q90) What problem will solve the namespace feature?

Answer: Libraries use multiple global identifiers to generate multiple providers.

Q91) Can I use this mouse on the constructor?

Answer: Yes, but avoid the invitation of virtual function from the constructor and try to pass this pointer from the boot list to other classes.

Q92) What is a default configuration?

Answer: A constructor who does not take any argument
There is a constructor that contains the argument (with the default value)

Q93) What is the Difference Between Class: Vector <int> X; And Class :: vector <int> X ()?

Answer: The first type of variable x type STD :: vector declares <int>. The latter gives a function x std :: vector <int>.

Q94) How does the main structure differ from the main class in C ++?

Answer: In C ++, a class resembles an organization with exception, naturally, all members of a class are individuals; An element members are civilians. Structures are not supported, but classes support.

Q95) Whether to define pure virtual activity?

Answer: A virtual class of pure virtual function is defined as a virtual function. It is implemented in the derived class. A program with a pure virtual function can not declare a program.

Q96) Can a Definition Be Defined?

Answer: An alternative tool is an argument tool. It is used by the packaging to keep objects as a type of argument for a type of type.

Q97) What Is The Variance Between Declaration And Definition ?

Answer: There are fundamentally two contrasts among announcement and definition:

  • In revelation no space is saved for the variable, announcement just tells about the ‘type’ of the variable we are utilizing or we will utilize int he program.
  • Definition then again saves the sapce for the variable and some underlying quality is given to it.
  • Another real distinction is that redeclaration isn’t a blunder though redefinition is a mistake,
  • In straightforward words, when we pronounce no space is saved for the variable and we can redeclare it in the program
  • On the other hand, when we characterize a variable some sapce is held for it to hold esteems in addition to some underlying quality is likewise given to it, aside from it we can’t give another definition to the variable, for example we can’t characterize it once more.

Model:
extern int x – > is a presentation though int y is definition.

Q98) If you want to share some functions or variables in some files maintaining the consistency how would you part it?

Answer: To keep up the consistency between a few records right off the bat place every definition in ‘.c’ document than utilizing outside statements place it in ‘.h’ document after it is incorporated .h record we can utilize it in a few documents utilizing #include as it will be in one of the header documents, along these lines to keep up the consistency we can make our own header document and incorporate it any place required.

Q99) What Do You Mean By Translation Unit?

Answer: A Translation Unit is a lot of source records that is seen by the compiler and it decipher it as one unit which is generally.file and all the header documents referenced in #include mandates.
At the point when a C preprocessor extends the source record with all the header documents the outcome is the preprocessing interpretation unit which when further handled deciphers the preprocessing interpretation unit into interpretation unit, further with the assistance of this interpretation unit compiler shapes the item record and at last structures an executable program.

Q100) Describe Linkages And Types Of Linkages?

Answer: we pronounce identifiers inside a similar degree or in the distinctive degrees they can be made to allude a similar article or capacity with the assistance of likages.
There are three kinds of linkages:

  • External linkage
  • Internal linkage
  • None linkage

Outer Linkages signifies ‘worldwide, non-static’ capacities or variable.
Model: extern int a1
Inside Linkages implies static variable and capacities. Precedent: static int a2
None Linkages implies nearby factors.
Precedent : int a3

Q101) Keeping In Mind The Proficiency, Which One Between If-else And Switch Is More Efficient?

Answer:

  • Between if-else chain and switch articulations, to the extent productivity is concerned it is difficult to state what one is increasingly effective on the grounds that them two forces scarcely any distinction as far as proficiency.
  • Switch can ne changed over into if else chain inside by the compiler.
  • Switch articulations are minimal method for writting a bounce table though if-else is far of writting conditions.
  • Between if-esle and switch proclamations, switch cases are prefered to be utilized in the programming as it is a smaller and cleaner method for writting conditions in the program.

Q102) What Are Structures And Unions?

Answer: While dealing with true issues we go over circumstances when we need to utilize diverse information type as one, C enables the client to characterize it possess information type known as structures and unions.Structures and associations assembles distinctive molecules of informations that include a given element.

Q103) What Is The Difference between Structures And Unions?

Answer:

  • Conceptually structures and associations are same, the differnce between them lies in their ‘Memory Management’ or in basic words the memory required by them.
  • Elements in structures are put away in coterminous squares, where as in associations the memory is distributed so that a similar memory allotted for one factor fills in as its memory at one occassion and as memory for another varioable at some other occassion.
  • Therefore, the essential distinction lies in the way mrmory is distributed to the two structures and associations.

Q104) I don’t get your meaning By Enumerated Data Type?

Answer: Specified Data type enables the client in characterizing its own information to type and furthermore offers the client a chance to characterize what esteems this sort can take.
The utilization of Enumerated Data Type maily lie when the program get increasingly confused or progressively number of programers are workin on it as it makes the program postings progressively intelligible.

Q105) What Are Preprocessor Directives In C?

Answer: The Preprocessor forms the source program before it is passed to the compiler. The highlights that preprocessor offers are known as Prepsocessor Directives.
Preprocessing mandates are lines in your program that begin with ‘#’. The ‘#’ is trailed by an identifier that is the mandate name. For instance, ‘#define’ is the mandate that defnes a large scale. Whitespace is likewise permitted when the ‘#’. A preprocessing order can’t be more than one line in ordinary conditions. Some mandate names require arguments.View replies in subtleties

Q106) What Is The Difference Between Global Variables And Local Variable?

Answer:

  • First, Global factors are the factors which can be gotten to from anyplace all through the program while nearby factors are those which must be gotten to inside the square of code in which they are made.
  • Second, worldwide factors are noticeable all through the program while nearby factors are not known to alternate capacities in the projects for example they are obvious inside the square of code in which they are made.
  • Third, worldwide factors are dispensed memory on Data Segament though nearby factors are assigned memory on the stack.

Q107) What Do You Mean By Volatile Variable?

Answer: Factors prefixed with the watchword unpredictable goes about as an information type qualifier. The unpredictable watchword endeavors to modify the default manner by which the factors are put away and the manner in which the compiler handles the factors.
It is a sort of guidance to the streamlining agent to not to enhance the varabli amid gathering.

Q108) What Is The Prototype Of Printf Function?

Answer:
Model of printf work is:
int printf( const scorch *format ,?)
In this the Second parameter: ‘?’ (Three consistent dabs) are known as called ellipsis which shows the variable number of contentions.

Q109) Define Macro?

Answer:

  • Macros are the identifiers that speak to articulations or articulations at the end of the day macros are piece of code which is been given a name. #define order is utilized to dedine a large scale.
  • Example, we have characterize a large scale i.e SQUARE(x) x*x.
  • Here the large scale decides the square of the given number. Large scale Declaration: #define name content.

Q110) What Is The Disadvantage Of Using A Macro?

Answer:
The significant burden related with the full scale is :
At the point when a full scale is summoned no sort checking is performed.Therefore it is critical to announce a large scale coreectly so it gives a right answer at whatever point it is called inside the program.

Q111) What Is A Void Pointer?

Answer: When we pronounce a variable as a pointer to a variable of sort void, it is known as void pointer. Another name for it is conventional pointer.
All in all we can’t have a void sort variable,but if the variable is of void kind it don’t point to any information and because of this it can’t be de-referenced.

Q112) What Is An Unnitialised Pointer?

Answer: When we make a pointer the memory to the pointer is distributed yet the substance or esteem that memory needs to hold stays immaculate. Unitialised pointers are those pointers which don’t hold any underlying quality.
Precedent: int *p; is said to be a unitialise pointer, it is recomended to initialise the pointer before really utilizing it as it a mistake.

Q113) What Is Dangling Pointer?

Answer: These are the pointers that don’t point to any object of proper kind. These are exceptional instances of memory vialation as they don’t point to any appropraite type.These emerges when some item is erased from the memory or when an article is deallocated in this way the pointer keeps on pointin to the memory area untill it is altered. Dangling pointers may prompt capricious outcomes.

Q114) What Do You Know About Near, Far And Huge Pointer?

Answer:

  • A close pointer is a 16 bit pointer to an item which is contained in the present portion like code fragment, information section, stack portion and additional section. It holds just counterbalanced location.
  • A far pointer is a 32 bit pointer to an item anyplace in memory. It must be utilized when the compiler dispenses a portion register, or we can say the compiler must assign section register to use far pointers. These pointers hold 16 bit fragment and 16 bit balance address.
  • Huge pointers are likewise far pointers for example 32 bit pointer the thing that matters is that the tremendous pointer can be expanded or diminished consistently between any portions and can have any an incentive from 0 to 1MB.

Q115) What Is Null Pointer?

Answer: Invalid pointer isn’t the unitialised pointer that can point anyplace, the NULL pointers are the one which don’t point anyplace that is which don’t point to any item or any capacity.

Q116) When Should I Use Unitbuf Flag?

Answer: The unit buffering (unitbuf) flag ought to be turned on when we need to guarantee that each character is yield when it is embedded into a yield stream. The equivalent should be possible utilizing unbuffered yield however unit buffering gives a superior execution than the unbuffered yield.

Q117) What Are Manipulators?

Answer: Controllers are the directions to the yield stream to change the yield in different ways. The controllers give a spotless and simple route for arranged yield in contrast with the organizing flags of the ios class. At the point when controllers are utilized, the organizing guidelines are embedded straightforwardly into the stream. Controllers are of two sorts, those that take a contention and those that don’t.

Q118) Differentiate Between The Manipulator And Setf( ) Function?

Answer: The contrast between the controller and setf( ) work are as per the following:
The setf( ) work is utilized to set the flags of the ios however controllers straightforwardly embed the designing directions into the stream. We can make client characterized controllers yet setf( ) work utilizes information individuals from ios class as it were. The flags put on through the setf( ) capacity can be put off through unsetf( ) work. Such adaptability isn’t accessible with controllers.

Q119) How To Get The Present Position Of The File Pointer?

Answer: We can get the present position of the record pointer by utilizing the tellp( ) part capacity of ostream class or tellg( ) part capacity of istream class. These capacities return (in bytes) places of put pointer and get pointer individually.

Q120) What Are Put And Get Pointers?

Answer: These are the long whole numbers related with the streams. The esteem present in the put pointer indicates the byte number in the record from where next compose would occur in the document. The get pointer indicates the byte number in the record from where the following perusing should happen.

Q121) What Does The Nocreate And Noreplace Flag Ensure When They Are Used For Opening A File?

Answer: nocreate and noreplace are record opening modes. A bit in the ios class characterizes these modes. The flag nocreate guarantees that the document must exist before opening it. Then again the flag noreplace guarantees that while opening a record for yield it doesn’t get overwritten with new one except if ate or application is set. At the point when the application flag is set then whatever we compose gets annexed to the current document. At the point when ate flag is set we can begin perusing or composing toward the finish of existing record.

Q122) Mention The Purpose Of Istream Class?

Answer: The istream class performs exercises explicit to include. It is gotten from the iosclass. The most generally utilized part capacity of this class is the over-burden >> administrator which canextract estimations of every single essential sort. We can remove even a string utilizing this administrator.

Q122) Can We Use This Pointer Inside Static Associate Function?

Answer: No! The this pointer can’t be utilized inside a static part work. This is on the grounds that a static part work is never called through an item.

Q123) What Is Strstream?

Answer: strstream is a sort of info/yield stream that works with the memory. It permits utilizing segment of the memory as a stream object. These streams give the classes that can be utilized for putting away the surge of bytes into memory. For instance, we can store whole numbers, buoys and strings as a surge of bytes. There are a few classes that actualize this in-memory designing. The class ostrstream got from ostream is utilized when yield is to be sent to memory, the class istrstream got from istream is utilized when input is taken from memory and strstream class got from iostream is utilized for memory protests that do both information and yield.

Q124) Can We Distribute Function Templates And Class Templates In Object Libraries?

Answer: No! We can incorporate a capacity layout or a class format into item code (.obj document). The code that contains a call to the capacity layout or the code that makes an article from a class format can get arranged. This is on the grounds that the compiler only checks whether the consider matches the affirmation (if there should arise an occurrence of capacity layout) and whether the item definition matches class presentation (if there should arise an occurrence of class format). Since the capacity layout and the class format definitions are not discovered, the compiler abandons it to the linker to reestablish this. In any case, amid connecting, linker doesn’t locate the coordinating definitions for the capacity call or a coordinating definition for article creation. In short the extended forms of layouts are not found in the item library. Subsequently the linker reports mistake.

Q125) Can We Use This Pointer In A Class Specific, Operator-over-burdening Function For New Operator?

Answer: No! The this pointer is never passed to the over-burden administrator new() part work since this capacity gets called before the article is made. Thus there is no doubt of the this pointer getting go to administrator new( ).

Q126) How To Allocate Memory Dynamically For A Reference?

Answer: No! It is beyond the realm of imagination to expect to distribute memory powerfully for a reference. This is on the grounds that, when we make a reference, it gets tied with some factor of its sort. Presently, on the off chance that we endeavor to dispense memory powerfully for a reference, it is unimaginable to expect to make reference to that to which variable the reference would get tied.

Q127) Can We Get The Value Of Ios Format Flags?

Answer: Indeed! The ios::flags( ) part work gives the esteem position flags. This capacity takes no contentions and returns a long ( typedefed to fmtflags) that contains the present organization flags.

Q128) When Does A Name Clash Occur In C++?

Answer: A name conflict happens when a name is characterized in more than one spot. For instance., two distinctive class libraries could give two unique classes a similar name. On the off chance that you attempt to utilize many class libraries in the meantime, there is a reasonable possibility that you will be not able accumulate or connection the program in view of name conflicts.

Q129) Define Namespace In C++?

Answer: It is an element in C++ to limit name crashes in the worldwide name space. This namespace watchword relegates a particular name to a library that enables different libraries to utilize a similar identifier names without making any name crashes. Moreover, the compiler utilizes the namespace signature for separating the definitions.

Q130) What Is The Use Of ‘utilizing’ Declaration In C++?

Answer: An utilizing statement in C++ makes it conceivable to utilize a name from a namespace without the extension administrator.

Q131) What Is An Iterator Class In C++?

Answer: A class that is utilized to cross through the articles kept up by a compartment class. There are five classifications of iterators: input iterators, yield iterators, forward iterators, bidirectional iterators, arbitrary access. An iterator is a substance that offers access to the substance of a compartment object without disregarding exemplification requirements. Access to the substance is conceded on an each one in turn premise all together. The request can be capacity request (as in records and lines) or some discretionary request (as in cluster files) or as indicated by some requesting connection (as in an arranged double tree). The iterator is a develop, which gives an interface that, when called, yields either the following component in the holder, or some esteem meaning the way that there are no more components to look at. Iterators conceal the subtleties of access to and refresh of the components of a holder class. The least complex and most secure iterators are those that license perused just access to the substance of a compartment class.

Q132) What Is A Null Object In C++?

Answer: It is an object of some class whose intention is to show that a genuine object of that class does not exist. One normal use for an invalid article is an arrival esteem from a part work that should restore an item with some predefined properties yet can’t discover such an item.

Q133) What Is Class Invariant In C++?

Answer: A class invariant is a condition that characterizes every substantial state for an article. It is an intelligent condition to guarantee the right working of a class. Class invariants must hold when an item is made, and they should be safeguarded under all tasks of the class. Specifically all class invariants are the two preconditions and post-conditions for all tasks or part elements of the class.

Q134) What Do You Mean By Stack Unwinding In C++?

Answer: Stack loosening up in C++ is a procedure amid exemption taking care of when the destructor is required every neighborhood object between where the special case was tossed and where it is gotten.

Q135) Define Pre-condition And Post-condition To A Member Function In C++?

Answer: Precondition: A precondition is a condition that must be valid on passage to a part work. A class is utilized effectively if preconditions are never false. A task isn’t in charge of doing anything reasonable if its precondition neglects to hold. For instance, the interface invariants of stack class say nothing regarding pushing one more component on a stack that is as of now full. We state that isful() is a precondition of the push task.
Post-condition: A post-condition is a condition that must be valid on exit from a part work if the precondition was substantial on passage to that work. A class is actualized accurately if post-conditions are never false. For instance, subsequent to pushing a component on the stack, we realize that isempty() should fundamentally hold. This is a post-state of the push task.

Q136) What Is An Orthogonal Base Class In C++?

Answer: On the off chance that two base classes have no covering techniques or information they are said to be autonomous of, or symmetrical to one another. Symmetrical in the sense implies that two classes work in various measurements and don’t meddle with one another in any capacity. The equivalent determined class may acquire such classes with no trouble.

Q137) What Is A Container Class? Mention the types Of Container Classes In C++?

Answer: A holder class is a class that is utilized to hold protests in memory or outer stockpiling. A compartment example worth following as a nonexclusive holder. A compartment class has a predefined conduct and an outstanding interface. A compartment class is a supporting class whose design is to conceal the topology utilized for keeping up the rundown of articles in memory. At the point when a holder class contains a gathering of blended articles, the compartment is known as a heterogeneous holder; when the holder is holding a gathering of items that are all the equivalent, the compartment is known as a homogeneous holder.

Q138) What Is An Adaptor Class Or Wrapper Class In C++?

Answer: A class that has no usefulness of its own is an Adaptor class in C++. Its part capacities shroud the utilization of an outsider programming segment or an item with the non-perfect interface or a non-object-situated usage.

Q139) What Is A Null Object In C++?

Answer: It is an object of some class whose reason for existing is to show that a genuine object of that class does not exist. One basic use for an invalid article is an arrival esteem from a part work that should restore an item with some predetermined properties yet can’t discover such an article.

Q140) What Is Class Invariant In C++?

Answer: A class invariant is a condition that characterizes every single legitimate state for an article. It is an intelligent condition to guarantee the right working of a class. Class invariants must hold when an item is made, and they should be protected under all tasks of the class. Specifically all class invariants are the two preconditions and post-conditions for all activities or part elements of the class.

Q141) What Do You Mean By Stack Unwinding In C++?

Answer: Stack loosening up in C++ is a procedure amid special case dealing with when the destructor is required every single neighborhood object between where the exemption was tossed and where it is gotten.

Q142) Define Pre-condition And Post-condition To A Member Function In C++?

Answer: Precondition: A precondition is a condition that must be valid on section to a part work. A class is utilized accurately if preconditions are never false. A task isn’t in charge of doing anything reasonable if its precondition neglects to hold. For instance, the interface invariants of stack class say nothing regarding pushing one more component on a stack that is as of now full. We state that isful() is a precondition of the push task.
Post-condition: A post-condition is a condition that must be valid on exit from a part work if the precondition was legitimate on passage to that work. A class is actualized effectively if post-conditions are never false. For instance, in the wake of pushing a component on the stack, we realize that isempty() should fundamentally hold. This is a post-state of the push task.

Q143) What Are The Conditions That Have To Be Met For A Condition To Be An Invariant Of The Class?

Answer: The condition should hold toward the finish of each constructor.
The condition should hold toward the finish of each mutator (non-const) task.

Q144) What Is An Accessor In C++?

Answer: An accessor is a class task that does not adjust the condition of an article in C++. The accessor capacities should be announced as const tasks.

Q145) Differentiate Between A Template Class And Class Template In C++?

Answer: Layout class: A nonexclusive definition or a parameterized class not instantiated until the customer gives the required data. It’s language for plain formats.
Class layout: A class format indicates how singular classes can be built much like the manner in which a class determines how singular articles can be developed. It’s language for plain classes.

Q146) What is the procedure for constructing an increment or decrement statement?

Answer: It can be done in two ways:

  • Using conventional operator i.e. x+1 or x-1
  • Using double increment and double decrement i.e. x++ or x–

Q147) How is Call by Value different from Call by Reference?

Answer:

  • In Call by Value, the variable’s value is sent as a parameter to function, while in Call by Reference the variable’s address is sent.
  • In Call by Value, the variable’s value sent as a parameter doesn’t get changed by any operation. In Call by Reference, variable’s values get easily affected.

Q148) What is commenting out? How is it beneficial in debugging?

Answer: Commenting out is a way of using /* */ around a code that might be the cause of errors in the code. It saves time as you don’t have to delete the code and type it again if required. If the code is error-free, you can remove the comment slash and execute it.

Q149) What is the main difference in for loop and while loop?

Answer: For loop is used when the number of iterations or the number of times loop will be executed, are known and while loop is used when number of iterations are not known.

Q150) Explain the term Stack?

Answer: Stack represents a data structure. It is also called LIFO or FILO approach. LIFO means Last In First Out or FILO means First IN Last Out. While retrieving the data from the stack, data on the top is extracted first. Data is stored in a stack using PUSH operation and retrieved using POP operation.

Q151) Explain sequential access?

Answer: Sequential access represents the way data is stored or retrieved from a file. In this type of file system, data are stored in sequential order. Data or records are placed one after another. While accessing a record, data is read one at a time, reaching the one requested.

Q152) Explain variable initialization?

Answer: Variable Initialization refers to assigning an initial value to the variable before using it in the program. Without initialization, unknown value is assigned to a variable automatically. This often leads to random outputs.

Q153) Explain spaghetti programming?

Answer: This kind of programming is associated with codes that get overlapped in the program. This is an unstructured approach to programming and is typically credited to lack of knowledge of programmer. Such programs are complex and difficult to analyze. It should be avoided.

Q154) How is Source Code different from Object Code?

Answer: The code written by the programmer is called Source code. It consists of keywords and commands for the computer. The extension used for source code in C is “.c” As computer cannot understand them, hence source code is compiled with the help of a compiler. The output of the compiler is called object code. It is in computer understandable format. The extension used for object code is “.obj”

Q155) Can you display quotes on-screen in C programming?

Answer: Yes. By using following format specifiers:

  • \’ to display a single quote
  • \” to display a double quote

Q156) How do we use ‘\0’ character?

Answer: A null character used to show string value’s termination or end.

Q157) Are these two symbols the same : = and ==?

Answer: They are different.

  • = symbol: Assignment operator used in operations of mathematical, to allocate value to a variable.
  • == symbol: Comparison operator or relational operator, used to compare values.

Q158) Explain modulus operator?

Answer: This operator is used to find the remainder in a division operation.  The symbol used for this is a percentage (%).
Example: 10 % 7 = 3, in this case, answer would be 3.

Q159) What is meant by nested loop?

Answer: A loop is called nested if it runs inside another loop. In this type of loop, there is one inner loop and outer loop. Inner loop executes as per iterations given in outer loop. Inner loop is executed first for every iteration.

Q160) Is operator <> valid?

Answer: Given operator <> is incorrect.

Q161) What is difference between compiler and interpreter?

Answer: They both are used to translate source code to object code. An interpreter will execute program one line at a time, whereas compiler will take the whole program and convert it in one go into object code. And then execute it. For interpreters, syntax errors may be encountered in the middle of program run, making it stop the process. Compiler checks for the syntax of program, run the program when there is no error only.

Q162) Explain the declaration for string variable?

Answer: Strings are declared using the char keyword. It holds one character only and string consists of many characters. Therefore, char array is used for string variables.
Example: char string_variable[50];
It declares a variable named ‘string_variable’ to store a string of 50 or less characters.

Q163) What is the use of curly brackets {}?

Answer: They are used for grouping of several code lines. They will work fine for single lines too.

Q164) Explain header files?

Answer: Library files or Header files contain two things: definitions and function prototypes.All the commands used in C programming are functions defined in header files. stdio.h is an example of a header file. It contains printf, scanf etc. definition along with prototypes.

Q165) Explain syntax error?

Answer: It is associated with errors of misspelled commands, misplaced symbol, ignored symbol etc.

Q166) What is a variable and a constant?

Answer: They both are identifiers and hold values. But the variable’s values can be modified, and constant’s values cannot be changed.

Q167) What is the procedure to access array values?

Answer: Each element of the array is associated with a number from 0 to total elements of array-1. To access any element of the array, the number associated with that element is used with name of the array.
For example, to access the 4th element of array, syntax would be array1[3], where array1 is the name of the array.

Q168) What kind of values can be stored using int?

Answer: Int is used to store integer values of the range -32768 to 32767.

Q169) How would you combine operators like \n and \t in a code line in C?

Answer: A statement like below can be used for this purpose:
printf (“C\n\n\’Program\’”) ”
It will give output as
C
Program

Q170) Do you declare every header file in C program?

Answer: Not all header files are to be declared in every C program. Whether a header file will be used in the program, depends on the commands or datatypes of that header files etc. used in the program.

Q171) What is use of keyword “void”?

Answer: Void is used in functions at the place of return type where it indicates that function will not return any value.

Q172) Explain compound statements?

Answer: Two or more statements executed together are called compound statements.

Q173) Why is algorithm used in C programming?

Answer: Creation of an algorithm before writing C program gives a sequence of steps used to create a solution for a given problem. It provides a blueprint for the program code.

Q174) Why are arrays used?

Answer: To store related data values of big chunks, arrays are used. Using arrays numerous variables are stored under one name. It eliminates the overhead of remembering name for each variable.

Q175) What is the difference between while and do-while loop?

Answer:

  • In while loop, the condition comes first and then the execution of code. Whereas in do-while loop, execution comes first and then the condition.
  • In the while loop, if the condition is false in the first run, code will never be executed. But in do while loop, code will be executed at least once, even when the condition is false in the first run.

Q176) Find the error in the following:

scanf(“%d”,variable1);

Answer: The only error in this statement is missing ampersand or & symbol. It should be used before the given variable ‘variable1’.

Q177) Is generation of random numbers possible in C?

Answer: It can be done using rand().

Q178) Why is a function reported as undefined by the compiler?

Answer: The most common reason is missing header file for that function. The header file contains declaration and definition of functions used in the program. If that particular header file related to function is not declared in the beginning of the program, this error will be indicated.

Q179) What is the use of comments?

Answer: To provide some code description, comments are used in a program. Comments are shown with /* comment here*/.  For single lines // is used.

Q180) Explain debugging?

Answer: The process of recognizing errors in a program is called debugging. While compilation, errors in the program make it stop working. Debugging makes sure that all the errors are removed. So that program will run smoothly and show the correct output.

Q181) What is the use of && operator?

Answer: && operator is called AND operator. All conditions given should be TRUE in AND prior to the execution of next command. If even one condition is FALSE, the entire condition statements are considered FALSE and next commands will not be executed.

Q182) Which operator is used commonly to find even and odd number?

Answer: Number of ways are there to find even and odd number in C. Most commonly, the remainder is checked, after dividing the number with 2. If the remainder is zero, number is even else odd. Hence, % operator is used.

Q183) What is the meaning of %10.2 in printf statement?

Answer: It serves two purposes:

  • Set spaces
  • Set decimal places

Q184) What is logical and syntax error?

Answer: Logical error occurs when the program is perfectly compiled but the output is not what was expected. It could be because of the wrong formula or command etc. Syntax errors is the result of incorrect commands, misspelled and unknown to compiler.

Q185) Explain control structures?

Answer: Control structures are used to explain the flow of program execution. Three types of control structures used in programming are:

  • Sequence: Flow is top to bottom. Every single statement is executed before going to the next statement for execution.
  • Selection: Conditions are used to decide which part of the code should be executed.
  • Repetition: Loops are used to execute some part of the code over and over.

Q186) Explain || operator?

Answer: The || is OR operator. Even if one condition is TRUE, entire conditional statements set evaluates to be TRUE.

Q187) Can you compare strings using “if” function?

Answer: It is used for numerical values comparison only. Strings can be compared using strcmp.

Q188) Explain preprocessor directives?

Answer: They are used with library files in the beginning of program. They are also used to declare constants. the use of preprocessor directives is the declaration of constants. They indicate preprocessing of program at the level of header files before compilation. Symbol for pre-processor is “#”

Q189) What is difference between mathematical and comparison operators?

Answer: Mathematical operators are used to performing mathematical functions viz. addition, subtraction, division, etc. While comparison operators are used to comparing the values, e.g. =>, =<, etc.

Q190) What is the precedence order of operators in C?

Answer: First priority: Unary operators (!, +, – and &)
Second priority: Mathematical operators (*, /, modulus %, followed by + and -)
Third priority: Relational operators <, <=, >= and >
Fourth priority: == and !=
Fifth priority: && and ||
Last level: =.

Q191) Can I writer name = “John”; ?

Answer: You can do this in another way too.
strcpy(name, “John”);

Q192) Can I find string length?

Answer: Using function strlen().
For example strlen(Variable Name)

Q193) Can you initialize a variable while declaring it?

Answer: Yes.
int a;
a=5
is same as int a=5;

Q194) Is C middle level language?

Answer: Yes. C has rich in features of high-level language and features helping it interact with hardware those are of low-level methods.
Well-structured approach and English-like keyword make it high-level language.
Direct access to memory structures makes it low-level language.

Q195) Name file extensions used in C.

Answer:

  • .c extension to save the Source codes.
  • .h for header files.
  • .obj for object code.
  • .exe for executable code.

Q196) How many types of time of error detection we have in C language?

Answer:

  • Compile Time Error
  •  Rune Time Error

Q197) What are the types of Keywords that supported in C, Write at least not less than 10

Answer: return, Static, typedef, extern, Case, Auto, short, goto, Break, Char

Q198) What is a ternary Operator pairs

Answer: It is a c Construct conditional expressions of the form
EX: exp1?exp2:exp3

Q199) Define unary Expressions?

Answer: An expression with only one operand and one operator is called unary expression.

Q200) Explain the term Implicit conversion?

Answer: The mixing of constants and variables of different types in an expression is known as Implicit conversion.

Q201) What are Iteration Statements?

Answer: Iteration Statements are used to execute a group of one or more statements repeatedly

Q202) Explain the Feature of Modularity in C language?

Answer: It is a structured programming language which mainly deals with the procedures. It is also termed as procedure-oriented language.

Q203) What is the use of ‘f’ in printf statement.

Answer: f represents format we generally use it in print and scan statements.

Q204) What is the main use of  ‘\0’ in c?

Answer: It refers to terminate the null character. Mainly to show the end of a string value.

Q205) Is it possible to use ‘int’ data type to store a value 32789? If so explain?

Answer: It is not possible because data type is capable to store values from -32768 to 32767. The given value in question cannot be stored at least as a long int.

Q206) List some advantages of inheritance?

Answer:

  • The code is reusability
  • time-saving on development of code

Q207) Define the term Mangling in C++?

Answer: This compiler will encode the parameter types with a function into a unique name.

Q208) Explain about the Preprocessor directive?

Answer: It is an Instruction or Set of instructions to the compiler itself.

Q209) How do you define an abstract class?

Answer: A class with no objects is called an abstract class.

Q210) List the features of Constructor?

  • It doesn’t have a return type
  • It executes when the object is declared
  • This can receive more no. of arguments.

Q211) Why run time error occurs?

Answer: This occurs due to unexpected output (or) input error, this generally happens when the time execution of code.

Q212) List some various concepts in OPPS?

Answer:

  • Abstraction
  • Class
  • Encapsulation
  • Data Binding

Q213) What will be datatype to store the Boolean value?

Answer: Bool, It is the primitive data type

Q214) Name some standard default streams in C++?

Answer: clog, cerr and cout

Q215) Which operator will be used in C++ to allocate dynamic memory?

Answer: The operator name called ‘NEW’.

Q216) Define class Template?

Answer: It is defined as a generic class. The keyword template is used to define a class template.

Q217) Will c++ support Exception Handling?

Answer: Yes it supports

Q218)  Expand STL in C++?

Answer: Standard template library.

Q219) What will be the size of a generic pointer in the c++( 32bit platform)?

Answer: size of a generic pointer is 4bytes

Q220) List the types of comments that can be used in C++?

Answer:

  • single line comment (//)
  • Multiple line comments (/*comment*/).

Q221) What is C?

Answer: C is a procedural style programming language. Data is
less than secured in C.

Q222) What is different between C &amp; C++?

Answer: The different between C &amp; C++ provides, C is Structure
language Secured less of C programming.
C++ is a procedural Object-Oriented programming modifier of
the class members to make it inaccessible for the outside users.

Q223) What were the variables in C?

Answer:

  • Int
  • float
  • char
  • string

Q224) What are the features of C++?

Answer: C++ features are,

  • Recursion
  • Object-oriented
  • Compiler based

Q225) What is the Oops?

Answer: Oops make its development and maintenance easier, the procedure-oriented programming language it is not easy to Manage.

Q226) Which is Standard in/output?

Answer: #include&lt;iostream.h&gt; included that standard in/output
library functions. It can use cin and cout methods to reading from
the input and writing an output respectively.

Q227) How to compile the C++ program?

Answer: There are two ways of compiling the program,

  • Click the compile menu &gt;&gt; compile sub menu
  • press &gt; ctrl + f9.

Q228) What are the data types in C++?

Answer: There are four types of data types,

  • Basic
  • Derived
  • Enumeration
  • User-defined

Q229) What are the types of operators?

Answer: If there are following the Operator,

  • Arithmetic
  • Relational
  • Logical
  • Bitwise

Q230) what is the oops concept?

Answer: The concept of Object-oriented programming provides the major purpose of c++ programming language, that concepts are inheritance, data binding, polymorphism, etc.