Programming in C and C++ homework Help at TutorEye
Flower

Are you a university or school looking for an online tutoring partnership ? Talk to Us

Best Homework Help For Programming in C and C++

Our experts are available 24/7 to help you with Programming in C and C++ homework problems!

Programming in C, C++

 

C is a low level, general purpose, procedural programming language. It was initially developed for the purpose of creating Operating Systems and Compilers by Dennis Ritchie. C provides lots of features which includes low level access to the memory, easy to read keywords and procedural flow.


C++ is a combination of both high and low level programming language and is general purpose. It supports various ways of programming which includes: Object Oriented, Functional and Procedural. It is used for developing games, browsers and Operating Systems.

 

 

Programming in C and C++ Sample Questions:

 

 

Question 1: Identify the correct identifier.

 

A) 12var

B) $sum

C) _name12 

D) break

 

 

Answer: _name12 

Explanation: Identifier name cannot start with numbers, it can only start

 

 

Get the full solution!

 

 

Question 2: What would be the output of the program below.


int var;


var = 1>2 ? 5<6 ? 2 : 3 : 6;


printf(“var”);

 

A) 2

B) 3

C) 6

D) None of these


Answer: C) 6

Explanation: Let us break the problem into chunks and variables:

 

 

Get the full solution!

 

 

Question 3: printf(“%d”, 5|2);

 

A) 5

B) 6

C) 7

D) 0

Answer: C) 7

Explanation: It is a Bitwise OR operator between 5 and 2.

 

 

Get the full solution!


 

Question 4:  What would be the output of the following program:


switch(2-1) {
        default:
            printf("2");
        case 1: 
            printf("1");
}

 

A) 1

B) 12

C) 21

D) None of these


Answer: A) 1

Explanation: First of all, the expression inside the switch would be evaluated to 1.

 

 

Get the full solution!


 

Question 5: See below statements and choose the correct option.

Can we define a function inside a Structure?

Is the size of the union equal to the sum of size of all the data members?

 

A) Yes, Yes

B) No, No

C) Yes, No

D) No, Yes

 

Answer:  B) No, No

Explanation: We cannot define a function inside a structure, we can do this inside a class.

 

 

Get the full solution!


 

Question 6: Which of the following is the default storage class?
 

A) Default

B) Auto

C) Register

D) Extern


Answer: B) Auto

Explanation: There is no storage class named “default”.

 

 

Get the full solution!


 

Question 7: Order of destructor is:

 

A) Same as the constructor

B) Opposite to constructor

C) Bottom to top

D) Both B and C

 

Answer: D) Both B and C

Explanation: Order of constructor is from top to bottom.

 

Get the full solution!


 

Question 8: What would be the output of the following code?

int a = ((5,6,7),(9,10,11));

cout<<a;

 

A) 5

B) 7

C) 9

D) 11

Answer: D) 11

Explanation: Compiler is going to read the statement from left to right and will assign the last value it gets to the variable.

 

Get the full solution!

 


Question 9: Find the output of the following code:

int a = 10;

cout << a++ + a++ + ++a;

 

A) 33

B) 31

C) 32

D) 34


Answer: D) 34

Explanation: It is going to evaluate the statement from left to right.

 

Get the full solution!


 

Question 10: Evaluate following statements:


A) Friend function can access private members of a class.


B) Friend function has access to this pointer.


C) Entire class can be declared as friend of another class.

 

A) True, True, True

B) True, False, False

C) True, False, True

D) False, True, True

 

Answer: C) True, False, True

Explanation: Friend function can access all the data members (public, private and protected).

 

Get the full solution!

 

Computer Science Question Answers Pages
 

We Are Different from Others!

Help with Programming In C And C Plus Plus