49,766 Topics
![]() | |
This is the famous counterfeit coin game in C++. # include <iostream> # include <cstring> # include <ctime> # include <cstdlib> # define coinVal 2; using namespace std; void gameInfo(); void generateGame(); void playGame(); int coins, counterfeitCoin; char typeOfCounterfeit; int main() { gameInfo(); generateGame(); } void gameInfo() { cout<<" Enter … | |
In my hw problem there is this code #include <iostream> using namespace std; int fun(int x) { if (x <= 0) return 0; if (x >= 9 && x % 2 == 1) return x - 1; if (x >= 9 || x % 3 == 0) return x - … | |
What are some safe sized datatypes? Inother words, stuff like size_t, uint32_t. They don't seem to change no matter what machine I use. I'm asking because the confusion comes in here: I'm not sure when to use long vs int. I did a sizeof(int) and sizeof(long) and they are both … | |
I made a simple program - conservative sequence integers with a sum, for example input: 15, the output should be 1, 2, 3, 4, 5 I made this program in c++ and it worked successfully, see below: #include <iostream> #include <string> using namespace std; int main() { int num, i, … | |
create a rectangle and find its area=w*h.create another rectangle with width and height as twice as the first rectangle and find its area using friend function in c++ | |
llo all,* im trying to build a simple software to modify words. from undesirable content from the internet for example : f*cking into sexual intercourse or something like that im very new into programming so any ideas would help me a lot. thanks | |
**Bold Text Here**please send a c++ program to implement stack push and pop operations using random number generatos | |
[code] class A { public: A() { cout<<"ctor A\n"; } virtual void func(int x) { cout<<"\nsj\n"; } }; int _tmain(int argc, _TCHAR* argv[]) { A objA; int *vptr = (int *)*((int *)&objA);// address of the virtual table typedef void (*fnptr)(int); fnptr f; f = (fnptr)*((int *)vptr+0);// address of func() within … | |
Hello Friends, As we know, when we have virtual function in our class, compiler smartly puts vptr(virtual table pointer) in our class to access correct function at run time. Can i access this vptr in my program, to use/manipulate this directly? Regards, Vivek | |
Hello, wondering if someone can help me. I'm working with a .wav file, and, I need to collect the header information. The header contains (roughly, 20 bits/bytes) before the actual data. And, each of this data is contained at different locations in the file. I need to read a particular … | |
Here is the problem:-[Click Here](https://docs.google.com/document/d/1m-Jh1lFGf46NtrVJDYbETGVY_uGgxsKivYPMaBqI26k/edit). .I have been trying it for more time but not getting how to solve the polynomial equation after converting from base 'b' to decimal i.e. my algorithm is:- size of array = max(A.size(),B.size(),Z.size()); store A in array as int; add B as int element by … | |
First off this is a homework question, please don't do my homework for me as nice as that would be... I have to make a program that can search a library for an author or title from a file and output all the matching lines. I am very close but … | |
Hey, I'm trying to create a simple Yatzy game in C++ (I'm new to programming) anyway here is my code: void gameMechanics(int& numberOfPlayers) //NumberOfPlayers are not used in this function at this point. { int diceResult = 0; int fiveDices[4]; string throwDices; cout << "Throw dices?(y/n): "; getline(cin, throwDices); if(throwDices … | |
i have just started learning c++ and i like to know after writing a c++ code how do u process it to become a software so that you can intsall it in another computer and use it | |
Hello everyone, I am working my way through the Forger's Win32 tutorial and am on the "Creating a Simple Application" part currently. I am using C++ (instead of C in the tutorial) and the WinGW compiler. When I compile the below code I get this error: main.cpp: In function 'LRESULT … | |
![]() | #include <iostream> #include <string> #include <cmath> using namespace std; //global varibals: char entered_characters[9999]; int direction_of_rotor1; int direction_of_rotor2; char alphabet_of_rotor1[26]; char alphabet_of_rotor2[26]; char rotor1_backward(char Letter); char rotor1_forward(char Letter); char rotor2_backward(char Letter2); char rotor2_forward(char Letter2); char print(char print_char); int main() { cout << "This is enigma machine:" << endl; cout << "*NOTE:This … |
I currently use this to serialize data, write it to shared memory so that another program can reconstruct it and use it: template<typename T> void Serialize(unsigned char* &Destination, const T &Source) { CopyMemory(Destination, &Source, sizeof(T)); //Destination += sizeof(T); //Not sure if to add this or not. } template<typename T> void … | |
/** @file Graph.h */ #ifndef GRAPH_FLIGHTFINDER #define GRAPH_FLIGHTFINDER #include <iostream> #include <fstream> #include <sstream> using namespace std; //graph implementation class FlightGraph { //A Node class to create pointer for graph implementation class Node { public : string name; double cost; Node * next; // constructor Node() { name=" "; next=NULL; … | |
So I have coded this program on formula method . #include <iostream> #include <cstdlib> #include <cmath> using namespace std; int main() { int a , b , c ; cout << " Enter the values of a , b , c " << endl; cin >> a ; cin >> … | |
Which of the following statements will display "Problem!" if bit 2 of flags is a '0'? | |
I am trying to implement periodic boundary conditions for 2d lattice. I did: int boundary2d(int xpos,int ypos,int stepx,int stepy){ int x=4,y=4; //grid size int **matrix; //the grid matrix int i=stepx+xpos; int j=stepy+ypos; if (i<0) { do { i+=Nx; }while (i>Nx-1); } if (i>Nx-1) { do{ i-=Nx; }while(i>Nx-1); } if (j<0) … | |
Hello, Please help. Below is my assignment and the code I've got so far. I'm still getting errors on overloading the member function on the printDay and prevDay. Design and implement a class dayType that implements the day of the week in a program. The class dayType should store the … | |
how to code this.. in 200 to 1 i need to decrease by 3 and displaying odd or even numbers.. can you help me.. ty :) | |
Hello! I'm relatively new to C++ and I'm learning about classes and objects. I've learned most of what I know from YouTube tutorials and some books. Well, in almost all of those, they mentioned that it was poor programming practice to make all your data members public, inside of a … | |
Hello, I am trying to read text from a simple text file. The text file contains a list of emails and zipcodes, formated as follows: email@site.com;zipcode where zipcode is 5 integers. I am having an issue with the getline function, my error is "no instance of overloaded function". Could someone … | |
In my project I've 8 edit boxes and i need to set each box with different font. But my code is setting all the boxes single font.. So how can i modify it?? void CTrail3Dlg::OnBnClickedButton1() { UpdateData(TRUE); CFontDialog dlg; // get font for current dialog, just to fill in LOGFONT … | |
How to create a dynamic library of the following code double sum(double a, double b) { return (a+b); } P.S> I've no idea about all these stuffs. Pls brief me all these. Just to know how these works. | |
Hello, I have a question that can be deducted from the title. When to use C++ inline functions and when not? Should I declare my constructors/destructors as inline? Should I declare functions that have at least a loop as inline? People say that declaring *small* functions as inline is a … | |
Hi, I'm writing a code to print weekday (ie: mon, tue, wed, thurs, fri, sat, sun) when user enter day/month/year. However, I do not know why this code doesn't work right. I didn't get any error. It actually works, but it just printed "Monday" for whatever date I putted in. … | |
IDC_FUNCTIONALITY MENU BEGIN POPUP "&File" BEGIN MENUITEM "E&xit", IDM_EXIT END POPUP "&Help" BEGIN MENUITEM "&About ...", IDM_ABOUT END END This is an example of a part of the default Foo.rc file distributed with VisualC++ 2010(Express), this is how this section of code was shipped. I'm interested in knowing why Exit … |
The End.