C++ General Interview Questions
Questions Answers Views Company eMail

A prime number is a number which is divisible only by itself and 1. Examples of the first few primes are 2, 3, 5, 7, 11. Consider writing a program which can generate prime numbers for you. Your program should read in and set a maximum prime to generate and a minimum number to start with when looking for primes. This program should be able to perform the following tasks: 1. Read the maximum number from user (keyboard input) to look for primes. The program should not return any primes greater than this number. 2. Read the minimum number from user (keyboard input) to look for primes. The program should not return any primes less than this number. 3. Generate and print out every prime number between the maximum prime and minimum number specified by the user.

1736

Write a program that will count the number of digits in an input integer up to value MAX_VALUE (2147483647). Thus, for an input of 5837 the output should be 4 digits Make sure that your program works for the numbers 0, 1, and 10. For the number 0, the output should be 1 digit

2 5086

Design a program to input a date from user in the form day/month/year (e.g. 2/6/2000) and report whether it’s a valid date or not. The program should take account of leap years. You will need to know that a leap year is a year that is exactly divisible by 4, except that century years are only leap years if they are divisible by 400.

1 2742

Write a program which is required to process the time of a clock in hours and minutes, entered from the keyboard. With this program, there are two requirements for any data entered by a user: 1. The data must be of the correct type (in this case, two ints). 2. The data must be in the correct range: this means that, for the minutes, negative numbers and any number above 59 must be rejected; for the hours, negative numbers and any number above 23 must be rejected. Output error message for invalid data input. Output the time one and a half hour after the time input. i.e. Hour: 22 Min: 32 One and a half hour after 22:32 is 00:02

1500

A company pays its salespeople on a commission basis. The salespeople receive $200 per week plus 9 percent of their gross sales for that week. For example, a saleperson who sells $5000 worth of merchandise in a week receives $200 plus 9 percent of $5000, or a total of $650. You have been supplied with a list of items sold by each salesperson. The values of these items are as follows: Item Value A 239.99 B 129.75 C 99.95 D 350.89 Write a program that inputs one salesperson's items sold in a week (how many of item A? of item B? etc.) and calculates and displays that salesperson's earnings for that week.

3402

write a program that reads in a file and counts the number of lines, words, and characters. Your program should ask the user to input a filename. Open the file and report an error if the file does not exist or cannot be opened for some other reason. Then read in the contents of the file and count the number of lines, words, and characters in the file. Also print additional information about the file, such as the longest and shortest words, and longest and shortest lines. For simplicity, we define a word to be one or more characters ending with white space (a space, tab, carriage return, etc.). Functions for checking the types of characters can be found in the ctype.h header file, so you want to include this header file in your program. For example, the sentence below could be all that is in a file. This sentence IT 104 is taught in C++. has 32 characters, one line, and six words. The shortest line is 32 characters. The longest line is 32 characters. The shortest word is 2 characters. The longest word is 6 characters

4839

int main() { int i ,a[i]; i = 0; a[i] = 10; cout<< a[i] << endl; return 0; } What will be output of this program?

HCL, Mphasis,

11 15938

CAN U SAY WHICH PROGRAMING LANGUAGE IS USED BY DOCTORS....?

1 3588

WHAT IS THE ABREVATION OF FORTRAN?

4 5511

WHO DEVELOPED C++?

6 10483

int *p = NULL; printf("%1d",p) ; what will be the output of this above code?

Microsoft,

3 11040

What is size of a empty class?

Microsoft, Tata Elxsi, Wipro,

7 11296

Inline parameters : What does the compiler do with the parameters of inline function, that can be evaluated in runtime ?

2004

how many trys can we write in one class

Cap Gemini,

3 6121

what is difference between internet and Internet?

College School Exams Tests, Microsoft, MIT, TCS,

12 13287


Post New C++ General Questions

Un-Answered Questions { C++ General }

What are the advantages of early binding?

602


What is a list c++?

564


Explain the difference between c & c++?

574


What is an incomplete type in c++?

758


What are virtual functions in c++?

675






Write some differences between an external iterator and an internal iterator?

571


What is a down cast?

598


Can I learn c++ in a week?

568


What is a memory leak c++?

581


What methods can be overridden in java?

661


What is the precedence when there is a global variable and a local variable in the program with the same name?

618


Can you be able to identify between straight- through and cross- over cable wiring? And in what case do you use straight- through and cross-over?

612


What is a template in c++?

627


Can comments be longer than one line?

609


How compile and run c++ program in turbo c++?

618