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.

7,990 Questions
C Programming
C++ Programming

How do you run a c program in turbo c plus plus?

You can directly press ctrl + f9 on your keyboard or you can go to the menu and then click on RUN.

337338339
Java Programming
C++ Programming

What is a sample of default constructor?

A default constructor is a constructor that takes no arguments.

Here's a sample:

class c

{

int a,b;

c() //Constructor 1

{

a=2;

b=1;

}

c(int x, int y) //Constructor 2

{

a=x;

b=y;

}

};

Here, Constructor 1 is called the default constructor, while Constructor 2 is a parameterized constructor.

309310311
C++ Programming
The Difference Between

What is difference between scanf and cin?

scanf is a function (available in C and C++)

cin is an istream object (C++ only)

Advice: when in doubt, use fgets+sscanf

289290291
Computer History
C Programming
C++ Programming

Machine code look like what?

Sample:

0AAC1801 BD07A2F3 4740A130 D25B4000

A18ABD07 A2F347D0 A0A04110 405C4150

287288289
C Programming
C++ Programming

What is a c program to implement trapezoidal and Simpson's methods?

ITS EASY...

TRY THIS OUT..

TRAPEZOIDAL METHOD

#include

#include

#include

float valcal(float x){

return (x*x*x);

}

int main(){

float a,b,h,c,I;

int n,i;

printf("THE TRAPEZOIDAL RULE:\n");

printf("---------------------");

printf("\n\n\nEnter the two limits and the no. of divisions:\n");

scanf("%f %f %d",&a, &b, &n);

h=(b-a)/n;

//printf("\nVALUE of h: %f\n", h);

c=a;

I=valcal(a)+valcal(b);

//printf("\nVALUE FOR a: %f\n", valcal(a));

//printf("\nVALUE FOR b: %f\n", valcal(b));

for(i=1;i

c=c+h;

//printf("\nValue of c for loop %d: is %f\n ",i,c);

if(c>=b){

printf("\n\nc>b\n\n");

break;

}

//printf("\nVALUE FOR %f: is %f\n",c, valcal(c));

I=I+(2*valcal(c));

//printf("\nI right now is %f", I);

}

printf("\n\n\nThe integration of x*x*x is: %f",(h*I)/2);

printf("\n\n\n");

system("pause");

}

SIMPSON'S 1/3RD METHOD

#include

#include

#include

float valcal(float x){

return (1/(1+x*x));

}

int main(){

float a,b,h,c,I;

int n,i;

printf("THE SIMPSON'S ONE-THIRD RULE:\n");

printf("------------------------------");

printf("\n\n\nEnter the two limits and the no. of divisions:\n");

scanf("%f %f %d",&a, &b, &n);

h=(b-a)/n;

//printf("\nVALUE of h: %f\n", h);

c=a;

I=valcal(a)+valcal(b);

//printf("\nVALUE FOR a: %f\n", valcal(a));

//printf("\nVALUE FOR b: %f\n", valcal(b));

for(i=1;i

c=c+h;

//printf("\nValue of c for loop %d: is %f\n ",i,c);

if(c>b){

printf("\n\nc>b\n\n");

break;

}

//printf("\nVALUE FOR %f: is %f\n",c, valcal(c));

if(i%2==0)

I=I+(2*valcal(c));

else

I=I+4*valcal(c);

//printf("\nI right now is %f", I);

}

printf("\n\n\nThe integration of x*x*x is: %f",(h*I)/3);

printf("\n\n\n");

system("pause");

}

NEED MORE HELP...

MAIL ME YOUR PROB... SEE YA

283284285
C Programming
C++ Programming

Why do you use getch in c plus plus?

getch function is used when you want to take some character from user, and this character is not displayed on the screen

277278279
C Programming
C++ Programming

Why conditional operator cannot be overloaded in C plus plus?

BCOZ

The conditional operator is essentially shorthand for the more verbose "if/else" statement and is best used for simple comparisons, even if it is possible to construct aribtrarily complex logic using the operator. Because the condition must evaluate to true or false, you can however overload the == and/or != operators to achieve the result you are looking for.

277278279
C Programming
C++ Programming

Trying to delete uninitialized pointer to object?

You cannot delete an uninitialized pointer, because there is no allocation for the object, and the pointer contains garbage. That includes the case where you attempted allocation and failed, but deletion is safe in that case because a NULL pointer is "safe" to delete, even though it does not point at anything.

273274275
C Programming
C++ Programming

How do you write a c plus plus program to print a ab abc abcd abcde?

#include<iostream.h>

#include<conio.h>

void main()

{

int i;

char j;

clrscr();

for(i=97;i<102;i++)

{

for(j=97;j<=i;j++)

{

cout<<j;

}

cout<<endl;

}

getch();

}

271272273
C++ Programming
Numbers

What is 200 plus 20?

200 plus 20 is 220.

257258259
C Programming
C++ Programming

What is meant by throw command in c plus plus?

A 'throw' statement throws an exception when it is generated within a try block. The exception is then caught by the corresponding catch block. For example,

void somefn()

{

float m, n;

try

{

cin>>m>>n;

if (n == 0)

throw(n);

else

cout<<(m/n);

}

catch (float x)

{

cout<<"Division by zero not possible";

}

}

255256257
Computer Programming
C Programming
C++ Programming

How do you make C plus plus Program Autorun?

A program cannot start itself if it is not running yet...

251252253
Computer Programming
C Programming
C++ Programming

What is an individual storage location in an array?

Element

247248249
Algebra
C++ Programming

Rules for function overloading?

same name must be declare as class name

245246247
Math and Arithmetic
C Programming
C++ Programming

How do you display the square root symbol on the output screen using Borland C Plus Plus?

Its Unicode value is 221A according to System tool Character map Advanced view Unicode subrange Math operators.

But I haven't done C in awhile, so I don't know how to or if you can.

ASCII value of root symbol is 251. In C we can print this symbol by printing the character value as below

printf("%c",251);

this will print the root symbol

235236237
Database Programming
C++ Programming

How circular queue differs from linear queue?

a circular queue has a multi purpose interface that draws power from the outlet but the linear draws power from the CPU and has a single divider which enables contortion

217218219
C Programming
C++ Programming
How To

How to program set Cardinality in C plus plus?

The cardinality of a set is simply the number of elements in the set. If the set is represented by an STL sequence container (such as std::array, std::vector, std::list or std::set), then the container's size() member function will return the cardinality.

For example:

std::vector<int> set {2,3,5,7,11,13};

size_t cardinality = set.size();

assert (cardinality == 6);

215216217
C++ Programming
ASP.NET
How To

HOW to display array elements C plus plus?

#include <iostream>

using std::cout;

using std::endl;

...

int main()

{

const int arraySize = 5;

double myArray [arraySize] = {0.0};

//Enter elements

...

//Display elements

for (int i = 0; i < arraySize; i++)

{

cout << myArray[i] << endl;

}

...

}

211212213
Mac OS
Java Programming
C Programming
C++ Programming

How do you compile and run C programs on the Macintosh?

The first step is to install the XCode developer tools that comes with OSX. You can do this by looking on your OSX install disc. There should be a folder for optional installs, and a package for XCode. This will automatically install gcc, a C compiler, on your machine. Next, find the Console in the Utilities folder. It opens a UNIX shell. Move to the directory that your c file is in (you can find more information about UNIX elsewhere if you need to). Let's say your C file is named myfile.c. To compile it, type: gcc myfile.c This will compile your program, and name the compiled program a.out. To run it, type: ./a.out I hope that helps. Brina

197198199
Math and Arithmetic
C Programming
C++ Programming
The Difference Between

What is the difference between array of pointers and pointer to an array?

An array of pointers is that for eg if we have array of 10 int pointers ie int *a[10] then each element that which is stored in array are pointed by pointers. here we will have ten pointers. In pointer to an array for eg int(*a)[10] here all the elements that is all the ten elements are pointed by a single pointer.

959697
Computer Programming
Java Programming
C++ Programming

What is function overloading in oop?

"Overloading" a function means that you have multiple functions with the same name, but different signatures. The signature of a function is its return type and number/types of parameters.

For example:

void foo(int a, char b)

can be distinguished from

void foo()

which can be distinguished from

void foo(double a)

which can be distinguished from

void foo(int a)

The program will call the correct function based off of the number and types of parameters it is given. So:

foo(1) will call the 4th example

foo(1.0) will call the 3rd example

foor() will call the 2nd example

and foo(1, 't') will call the 1st example

Note that MOST programming languages do not allow you to distinguish between function signatures by return type, thus:

void foo()

and

int foo()

is not allowed.

Function overloading should not be confused with function overriding. Overriding involves inheritance and is related to polymorphism.

199200201
C++ Programming

When did CPP start?

I believe it was in 1967

195196197
Java Programming
C++ Programming

Is the default access specifier same as protected?

No. The default access specifier on a class type object is private. On a non-class type structure, it is public.

193194195
Java Programming
C++ Programming

What are the potential advantages of treating two related classes as subclasses of some superclass?

If you do that, many definitions and later changes have to be done but in a single place, where they will affect the two (or more) subclasses.

616263
C Programming
C++ Programming

To sort elements of array using pointers?

#include
#include

int main(void)
{
int item[100];
int a, b, t;
int count;
printf("How many numbers? ");
scanf("%d", &count);

for(a = 0; a < count; a++)
scanf("%d", &item[a]);

for(a = 1; a < count; ++a)
for(b = count-1; b >= a; --b) {
if(item[ b - 1] > item[ b ]) {
t = item[ b - 1];
item[ b - 1] = item[ b ];
item[ b ] = t;
}
}


for(t=0; t

return 0;
}

181182183

Copyright © 2020 Multiply Media, LLC. All Rights Reserved. The material on this site can not be reproduced, distributed, transmitted, cached or otherwise used, except with prior written permission of Multiply.