answersLogoWhite

0

📱

C++ Programming

Questions related to the C++ Computer Programming Language. This ranges all the way from K&R C to the most recent ANSI incarnations of C++, including advanced topics such as Object Oriented Design and Programming, Standard Template Library, and Exceptions. C++ has become one of the most popular languages today, and has been used to write all sort of things for nearly all of the modern operating systems and applications." It it a good compromise between speed, advanced power, and complexity.

2,546 Questions

How we can Write a program in c plus plus to input values into a table sort these values in ascending order and print them on the screen in tabular form?

Use a multiset to sort the input automatically.

int main()

{ std::multiset<int> set;

int i;

while (std::cin >> i)

set.insert (i);

for (auto it=set.begin(); it!=set.end(); ++it)

std::cout << i << std::endl;

}

Why is object code necessary?

Object code is necessary, because object code is the actual instructions, or machine language, that the computer executes. Object code is the output of the compiler, as it translates the higher level language into the machine language. It is also the output of the linker, as it combines object code modules from the compiler output and the various libraries in its process of building a fully linked load module.

The name of institute of c plus plus in mira road?

Swami Vivekanand College of Distance Education, recently exposed for issuing fake entrance certificates.

C plus plus characters are internally treated as integers why?

Because a character is an integer, not a real number. You probably meant int rather than integer, but no implementations of C++ treat a char as an int. All implementations are guaranteed to evaluate sizeof(char) as being exactly 1 (byte). Moreover, a string of 4 characters will occupy exactly 32-bits, not 128-bits (assuming an int is 32-bits, which is entirely dependant upon the implementation).

When processing single characters the CPU will treat them according to the system's word length (which is 32 bits on a 32-bit machine), but that has nothing to do with C++ treating a char as an int, that's purely down to the architecture. After all, it's just as quick to manipulate 32 bits as it is to manipulate 8 bits on a 32-bit system. On a 64-bit system, a single char will be treated as if it were 64 bits long (8 bytes) for the same reason.

What is the Streaming data in the context of C plus plus refers to what?

Streams provide a unified, generic, input/output mechanism in C++. They allow a consistent method of inserting or extracting data from any physical storage medium that supports a stream implementation, such as a filestream or a stringstream, without the need to know the details of that medium. All streams operate in exactly the same way. To extract data from an input stream, use the extraction operator (>>). To insert data into a stream, use the insertion operator (<<). Some streams are omni-directional (input-only or output-only), while others are bi-directional (both input and output).

What is the function of troponin?

Troponin is attached to the protein tropomyosin and lies within the groove between actin filaments in muscle tissue. In a relaxed muscle, tropomyosin blocks the attachment site for the myosin crossbridge, thus preventing contraction. When the muscle cell is stimulated to contract by an action potential, calcium channels open in the sarcoplasmic reticulum and release calcium into the sarcoplasm. Some of this calcium attaches to troponin, causing a conformational change that moves tropomyosin out of the way so that the cross bridges can attach to actin and produce muscle contraction.

Similar features of c and c plus plus?

The similar features of C and C++ is C itself. C++ is a superset of C, thus every C program is (or can be) a valid C++ program. C++ is more consistent and stricter than C, however, so some C programs may need some minor alterations in order to become C++ compliant. For that reason it is simpler to enumerate the differences than it is to enumerate the similarities.

The following list enumerates all the differences with respect to a C programmer compiling C code under C++.

1. In C++, assigning from void* is not permitted -- you must use an explicit cast.

int *x = malloc (sizeof (int) * 10); // C version

int *x = static_cast<int*>( malloc (sizeof (int) * 10)); // C++ version

2. In C++, a function MUST be declared before it can be used. Although most C programs do follow this convention, it is not strictly enforced.

3. In C++, we cannot invoke the main function from within another function of the same program.

4. In C++, main must return an int, however return 0 is implied if not explicitly stated at the end of the function.

5. In C++, multiple declaration of global variables is not permitted.

Provided a C programmer adheres to these conventions, the program will compile under C++. Everything else in C is fully compliant with C++.

Why is nimu plus medicine used?

Nimu Plus is a medication also known as paracetamol. It is a non-opiate pain medication prescribed for headaches and muscle aches.

How do you sovle 3c plus 5 equals c plus 15?

It is:-

3c+5 = c+15

Subtact 5 and c from both sides:

2c = 10

Divide both sides by 2 to find the value of c:

c = 5

What is Parameter Passing and Returning values.. in Programming.. preferbly Visual Basic?

Parameters are the variables you pass to functions. Return values are the variables that are returned by those functions. Values can also be returned by the parameters themselves (such parameters are said to be output parameters).

The variables you pass and return from functions will either be by value or by reference. Only references can be output parameters, since passing by value creates an automatic copy of the value which falls from scope when the function returns. Pointer variables are always passed by value. To pass a reference to a pointer you must pass a pointer to the pointer, which is itself passed by value, but refers to the pointer.

Constant references are the preferred method of passing variables to functions, since there is no need to copy the variable you pass and because it is constant, the original value is left unaltered. Non-constant reference is the next best method, but only if you expect changes to be reflected back in your value (an output parameter). If you do not expect changes, then you must pass by value or, when that isn't an option, create a copy of your value and pass by non-constant reference. The only difference is that passing by value automatically destroys the copy when the function returns.

Ignoring output parameters, a function can only return, at most, one value. A function that returns void has no return value, however it is good practice to always return something, even if only an integer to indicate whether the function was successful (zero) or not (non-zero). If the function is a logical function, such as Add( X, Y ), or an accessor, such as GetName() then it makes more sense to return the actual result of the function via the return value. If you need more than one return value, then you must use output parameters, passed by reference, which allows the return value to be used as an error indicator.

Generally you will want to store the return value of a function, especially if the return value is a memory allocation. If you don't store the return value, the value is lost forever, unless you re-call the function with the same parameters, which is highly inefficient. However, if you only need to know the result of a function once, you don't need to store it, so long as you act upon it immediately, usually as part of a conditional expression. E.g.,

int x, y; // Uninitialised, values unknown.

if( x + y == 12 ) // call the int::operator+ function.

// x+y is definitely 12.

else

// x+y is definitely not 12, but the actual sum is no longer known at this point.

What is mean by pointer in c plus plus?

Pointers are objects that point (in memory) to another object. Their usefulness lies in their ability to dynamically manage memory and data structures. They are also very dangerous because there is a tendency to not adhere to all the rules when dealing with pointers and dynamic memory.

1. Never use a pointer without initializing it with a proper allocation request.

2. Always check a memory allocation request for failure.

3. Never use a pointer beyond the bounds of the original allocation.

4. Never use a pointer after it has been deallocated.

5. Alway deallocate a prior memory allocation when you are done using it.

If xyz is the name of an object in memory, then &xyz is it's address. If pxyz is a pointer to an object of type xyz, then the statement pxyz = &xyz would initialize pxyz to point to xyz. At that point, you could refer to xyz using *pxyz.

If pabc is a pointer to an object of type abc, then the statement pabc = malloc(100*sizeof(abc)) would allocate an array of 100 objects of type abc from the heap, and initialize pabc to point to the first one. You could then use the array with pabc[n] syntax or with *(pabc+n) syntax. You would deallocate the array with free pabc.

C++ Specific:

If pqrs is a pointer to an object of class type qrs, then the statement pqrs = new qrs would allocate memory from the heap, initialize pqrs to point to the object, and fire the constructor for that class. You could then invoke methods of the class with pqrs->method(), etc. or you delete the class with delete pqrs, said deletion firing the destructor.

Make a pascal using c plus plus?

Please make your question more clear. Qhat do you want to do? Rewrite the programming language Pascal? Convert c++ code to Pascal? Create a Pascal triangle? Make a baby son that's called Pascal? (btw, that last thing has to be done in hardware)

Do abstract classes and pure virtual functions have practical value in the real world?

Yes. An abstract class is a conceptual class (an incomplete class) that provides a generic interface for two or more actual classes (the derived classes).

For instance, a shape is not an actual object, nor is a mammal. They are simply a type of object; a conceptual object. A square is an actual type of shape, just as a golden Labrador is a specific breed of dog, an actual mammal. The conceptual classes merely provide a generic interface to the actual object, but do not have enough information to implement that interface. For instance, all shapes can be drawn, but without knowing what type of shape to draw, the conceptual shape cannot implement the draw method, it can only provide the interface. By declaring the shape::draw method to be pure-virtual, you not only ensure that you cannot instantiate a shape by itself (it is merely an abstraction), you also ensure that all the derivatives of the shape class provide a specific implementation of that interface.

A structure for Freon 14 tetrafluoromethane?

Commercially known as Freon 14, the chemical tetrafluoromethane is made up of 4 (hence the tetra-) fluoride atoms bonded to 1 carbon atom. The simple form is CF4. The methane portion refers to CH4,and in this case, the fluoride takes the place of the hydrogen atoms.

Carbon does form chains, as can be seen in carbohydrates. In fact, the simplest carbon chain, ethane, is C2H4.

See the Related Links below for a few easy to comprehend pictures.

Is a function call a form of branching in C plus plus?

No. A branch is akin to a goto statement in procedural programming. The code branches off to a new code segment, never to return. A function call is akin to a subroutine in structured programming. When the subroutine is finished, control is returned to the instruction immediately following the function call, just as if the function's code were inline expanded at the call site.

What is go-to unconditional in c plus plus?

An unconditional goto is a goto that has no associated conditional expression. The following example demonstrates conditional and unconditional goto statements.

int x=rand();

if (x)

goto label_1; // conditional goto (when x is non-zero)

else

goto label_2; // conditional goto (when x is zero)

label_1:

// ...

goto label_3; // unconditional goto (jump past label_2)

label_2:

// ...

label_3:

// ...

What is logic error in c plus plus?

A logic error is an error that will not cause the program to crash, but will nevertheless cause the program to behave in a way that is unexpected or otherwise incorrect. By way of example, a program that converts Fahrenheit to Celsius will behave incorrectly if the program is written to multiply and divide first instead of adding or subtracting first (F-32*5/9=C instead of (F-32)*5/9=C). In this case, simply forgetting the enclosing parentheses caused the logic error.

What are the private data members of kilometer class in c plus plus?

C++ does not have a built-in kilometre class. If you have such a class, it was provided for you by a third party. However, your IDE should be able to show you the members, including private members. I'd imagine such a class would have a private float or double member to store the actual number of kilometres it represents, and perhaps some public methods to convert the number to other formats, such as millimetres, centimetres, miles, yards, inches, etc.