adplus-dvertising
frame-decoration

Question

What will be the output of the following program?
#include<iostream.h>
#include<string.h> 
class Compscibits
{
    char str[50]; 
    char tmp[50]; 
    public:
    Compscibits(char *s)
    {
        strcpy(str, s);
    }
    int BitsFunction()
    {
        int i = 0, j = 0; 
        while(*(str + i))
        {
            if(*(str + i++) == ' ')
                *(tmp + j++) = *(str + i);
        }
        *(tmp + j) = 0; 
        return strlen(tmp); 
    }
};
int main()
{
    char txt[] = "Welcome to Compscibits.com!";
    Compscibits objBits(txt); 
    cout<< objBits.BitsFunction();
    return 0;
}

a.

1

b.

2

c.

24

d.

25

Answer: (b).2

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What will be the output of the following program?

Similar Questions

Discover Related MCQs

Q. When an object goes out of scope, which function is called automatically?

Q. Destructors do not receive parameters and do not

Q. Scope resolution operator is denoted by

Q. A class data members and member functions belongs to

Q. Passing arguments to a destructor, or specifying return type to destructor, causes

Q. A destructor for a class is denoted by

Q. Access functions that is used to test the truth or falsity of conditions, is called

Q. If no constructor is defined for a class, the compiler

Q. A constructor that can be invoked with no arguments, is called as

Q. If a class wants to allow clients to read private data, the class can provide a

Q. Member selection operator is denoted by

Q. Which operator is combined with a pointer to an object to access that object's member?

Q. Non-member functions are defined as

Q. Member functions defined in a class definition are automatically

Q. Constructors do not have

Q. Which preprocessor directives are used to prevent header files from being included more than once in a program?

Q. The assignment operator can be used to assign an object to another object of the same type, this assignment by default performed by

Q. Which operator accesses a structure member via the object's variable name?

Q. Which keyword is used for structure definition?

Q. Aggregate data types built using data of other types, is called as