Top 150 C++ Interview Questions and Answers

Updated 3 Jul 2025

Asked in S&P Global and 27 others

1w ago

Q. Explain STLC.

Ans.

STCL stands for Software Test Case Language, a scripting language used for automated testing.

  • STCL is used to write test cases for software testing.

  • It is a scripting language that allows for automated testing.

  • STCL is used to define the steps and expec...read more

Q. How do you use the TC modifier?

Ans.

The Tc modifier is used to indicate that a service was performed as a component of a larger service.

  • The Tc modifier is used for technical components of a service.

  • It is used to indicate that a service was performed using equipment owned by the provide...read more

1w ago

Q. Why do we use the volatile keyword?

Ans.

Volatile keyword is used to indicate that a variable's value can be changed unexpectedly.

  • Volatile keyword is used in multi-threaded programming to ensure that the value of a variable is always read from memory and not from a cache.

  • It is also used in ...read more

Asked in UBS

2w ago

Q. What is defaulting?

Ans.

Defaulting is the failure to fulfill a financial obligation or debt repayment.

  • Defaulting occurs when a borrower fails to make timely payments on a loan or debt.

  • It can result in penalties, fees, and damage to the borrower's credit score.

  • Examples inclu...read more

Are these interview questions helpful?
2w ago

Q. What is managed and unmanaged code in C++?

Ans.

manage and unmanage are not standard terms in C++

  • There are no standard terms or concepts called 'manage' and 'unmanage' in C++

  • These terms might be specific to a particular framework or library

  • Without more context, it is difficult to provide a specifi...read more

1w ago

Q. What is the use of the main function?

Ans.

Main function is the entry point of a program. It is used to execute the code in the program.

  • Main function is required in every program written in C, C++, Java, etc.

  • It is the first function to be executed when the program starts.

  • It can take command l...read more

Share interview questions and help millions of jobseekers 🌟
man with laptop

Asked in AVASOFT and 5 others

3d ago

Q. Why C++?

Ans.

C++ is a powerful and versatile programming language widely used in system engineering.

  • C++ offers high performance and low-level control, making it suitable for system-level programming.

  • It supports object-oriented programming, allowing for modular an...read more

4d ago

Q. How are static functions used in C/C++?

Ans.

Static functions in C/C++ are functions that can only be accessed within the same file they are defined in.

  • Static functions are declared using the 'static' keyword.

  • They cannot be called using an object or instance of a class.

  • They are useful for encap...read more

Asked in SAP

1w ago

Q. What is preinitialization?

Ans.

Preinitialization is the process of initializing data or objects before they are actually needed.

  • Preinitialization can improve performance by reducing the time needed to initialize data or objects when they are actually needed.

  • It can also help to avo...read more

Asked in Intellect

1w ago

Q. What does #include perform?

Ans.

The #include directive is used to include a file in the source code.

  • It allows the programmer to use code from other files in their program.

  • The included file is processed by the preprocessor before compilation.

  • The syntax is #include or #include "file...read more

C++ Jobs

Larsen & Toubro (L&T) logo
Embedded Software Engineer 3-8 years
Larsen & Toubro (L&T)
3.9
Surat
Emerson logo
Software Developer 10-20 years
Emerson
4.1
Pune
Vvdn Technologies logo
Tech Lead II Bluetooth Host development II VVDN Technologies 7-12 years
Vvdn Technologies
3.6
Bangalore / Bengaluru

Asked in Lodha Group

2w ago

Q. How do you onboard new Customer Partners?

Ans.

New CPS can be included by identifying potential clients, building relationships, and providing value through product knowledge and excellent customer service.

  • Identify potential clients through market research and networking

  • Build relationships throug...read more

5d ago

Q. What are the parameters of a complete LFT?

Ans.

Complete LFT parameter refers to a comprehensive set of liver function tests that assess the overall health and function of the liver.

  • Complete LFT parameter includes tests such as ALT, AST, ALP, bilirubin, albumin, and total protein.

  • These tests help ...read more

Asked in Synopsys

1w ago

Q. Where should const pointers be declared?

Ans.

Const pointers should be declared in the same scope as the variable they point to.

  • Declaring const pointers in the same scope as the variable they point to ensures that the pointer cannot be used to modify the variable.

  • If the pointer is only used with...read more

Asked in Amadeus

1w ago

Q. common questions like

Ans.

The question is about the common header file in C++.

  • The header file is used for input/output operations in C++.

  • It provides classes like cin and cout for reading and writing data.

  • It also includes classes for file input/output operations like ifstrea...read more

Asked in Dell

2w ago

Q. What is the difference between char a[] = "string"; and char *p = "star";?

Ans.

The first declaration creates an array of characters, while the second declaration creates a pointer to a character.

  • char a[] = "string"; creates an array of characters with the size determined by the length of the string.

  • char *p = "star"; creates a p...read more

Asked in GS Lab and 2 others

4d ago

Q. Write code for the same

Ans.

Code to find the sum of all even numbers in an array

  • Create a variable to store the sum

  • Loop through the array and check if each number is even

  • If the number is even, add it to the sum variable

  • Return the sum variable

Asked in Piaggio

2w ago

Q. You can work one type by various ways?

Ans.

Yes, there are multiple ways to work on one type in computer operations.

  • Using different programming languages

  • Using different software tools

  • Using different algorithms or approaches

  • Using different hardware configurations

Q. What is CNC programming?

Ans.

CNC programming is the process of creating instructions for a computer-controlled machine to perform specific tasks.

  • CNC stands for Computer Numerical Control

  • Programs are created using CAM software

  • Instructions are written in G-code

  • Used in manufacturin...read more

Q. Write a function that removes characters before a '#' symbol based on the number of '#' symbols. For example, 'abc#d' should become 'abcd', and 'abc##d' should become 'ad'.

Ans.

Write code to remove number character before hash based on count of hash

  • Count the number of hashes in the input string

  • Loop through the string and remove the character before the hash based on the count of hashes

  • Return the modified string

Q. Explain what a modifier is.

Ans.

A modifier is a word or phrase that describes or changes the meaning of another word or phrase in a sentence.

  • Modifiers can be adjectives, adverbs, or phrases.

  • They provide additional information about the subject, verb, or object in a sentence.

  • Example...read more

Asked in Intuit

2w ago

Q. For what purposes is the virtual keyword used in C++?

Ans.

The virtual keyword is used in C++ for creating virtual functions and implementing polymorphism.

  • Used to create virtual functions that can be overridden by derived classes

  • Allows for dynamic binding of functions at runtime

  • Used in implementing polymorph...read more

Asked in Wipro

1w ago

Q. Implement addition without using the '+' operator.

Ans.

Implementing addition without using the + sign.

  • Use bitwise operators like XOR and AND to perform addition.

  • Convert the numbers to binary and perform addition bit by bit.

  • Use recursion to add the numbers.

  • Use a lookup table to perform addition.

  • Use the Ma...read more

Asked in Infosys

1w ago

Q. Given an array of integers from 1 to n with one number missing, write a program to find the missing number.

Ans.

Program to find the missing number from an array of integers.

  • Create an array of integers with the given values.

  • Loop through the array and check for missing numbers.

  • Print the missing numbers.

  • Alternatively, use mathematical formula to find the missing ...read more

Asked in Amazon and 62 others

2w ago

Q. Write the code.

Ans.

Code to print the first 10 even numbers starting from 2

  • Use a loop to iterate through the numbers

  • Check if the number is even using the modulo operator

  • Print the number if it is even and increment the count

  • Stop the loop once 10 even numbers have been pr...read more

1d ago

Q. What is the new operator?

Ans.

The new operator is used to dynamically allocate memory for an object at runtime.

  • It returns a pointer to the newly allocated memory.

  • It can be used to allocate memory for built-in types, user-defined types, and arrays.

  • The syntax is: new type;

  • Example: ...read more

Asked in Micro Labs

1w ago

Q. Explain how a vacuum circuit breaker (VCB) works.

Ans.

VCB stands for Vacuum Circuit Breaker, which is an electrical switch that uses vacuum as the dielectric medium.

  • VCB is used to protect electrical equipment from damage caused by overcurrents and short circuits.

  • It is commonly used in high voltage power...read more

Asked in Cognizant

5d ago

Q. Write a program to validate a phone number consisting of only 1s and 0s.

Ans.

The program prints a pattern of alternating 1s and 0s in a specific sequence.

  • Use a loop to iterate through the given sequence of numbers

  • Inside the loop, check the length of each number and print the corresponding pattern of 1s and 0s

  • Repeat the patter...read more

Asked in Flycatch and 3 others

1w ago

Q. What is CAS?

Ans.

CAS stands for Columnstore Archive Storage in Azure SQL Database.

  • CAS is a storage tier in Azure SQL Database that is optimized for cold data storage.

  • It is designed to store large amounts of data that is infrequently accessed.

  • CAS uses columnstore inde...read more

Asked in McAfee

3d ago

Q. What is an initializer list in C++? Provide an example.

Ans.

Initializer list is a syntax in C++ to initialize objects with a list of values.

  • Initializer list is enclosed in curly braces {}.

  • It can be used to initialize arrays, structs, and classes.

  • Example: int arr[] = {1, 2, 3};

  • Example: struct Point { int x, y;...read more

3d ago
Q. What is the new keyword in C++?
Ans.

The new keyword in C++ is used to dynamically allocate memory for an object or array.

  • Used to create objects on the heap: MyClass* obj = new MyClass();

  • Used to create arrays on the heap: int* arr = new int[10];

Previous
1
2
3
4
5
Next

Interview Experiences of Popular Companies

TCS Logo
3.6
 • 11.1k Interviews
Accenture Logo
3.8
 • 8.6k Interviews
Infosys Logo
3.6
 • 7.9k Interviews
Wipro Logo
3.7
 • 6.1k Interviews
Cognizant Logo
3.7
 • 5.9k Interviews
Capgemini Logo
3.7
 • 5.1k Interviews
HCLTech Logo
3.5
 • 4.1k Interviews
Tech Mahindra Logo
3.5
 • 4.1k Interviews
LTIMindtree Logo
3.7
 • 3k Interviews
View all
interview tips and stories logo
Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories
C++ Interview Questions
Share an Interview
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 Lakh+

Reviews

10L+

Interviews

4 Crore+

Salaries

1.5 Cr+

Users

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits