I'm new to program breadth first search and for my assignment we have to implement a breadth first search graph and output the order of the traversal. The problem is when I run my program I do not get any output from my traversal. All I get is "Breadth First Search Traversal starts at Vertex 2 and the order is: "
Here is my Queue class
//Declaration of node struct node{ int info; node *next; }; //Defining Queue class class Queue{
I am attempting to assign "randomChoice" as the array index of the "listOfWords" array then copy "listOfWords[randomChoice] to "selectedWord". I am not sure if it is that I do not fully understand the use of strcopy() or something wrong with my arrays.
This is my error:
Code:
hangman.cc: In function ‘void SelectWord(char (*)[80], int, char*): hangman.cc:84: error: invalid conversion from 'char' to 'const char*' And my code: Code: #include <iostream>#include <fstream> #include <cstdlib> #include <cassert> #include <cstring>
write a program which contains two global variables:
1.Account number (integer) 2.Account Balance (float)
and three functions :
A function called set values which sets initial values for account number and account balance,
A function called set values which prompt user to enter the values of the above variables,
A function called input transaction which reads a character value for transaction type that is D (for deposit) and W (for withdrawal ) and a floating point value for transaction amount which updates the account balance .
Implement a pointer to call each of the functions using C++.
So, according to standard the temporary objects should not be destroyed before full expression execution (expression whitch is not a part of another expression).
The question is: is StreamLogger() << "foo1" << "foo2" << "foo3"; full expression or not?
I'm playing with the idea of a singleton base class, but I'm having an issue with how to implement the GetInstance() function in the base class. Since I'm trying to make this ridiculously simple for the child, I'd like to handle that in the base.
class Singleton { private: static Singleton* instance; Singleton() { Construct(); } // Private to avoid other instances
I am supposed to implement the member functions of class Person.
class Person { public: Person(); Person(string pname, int page); void get_name() const; void get_age() const;
[Code] ....
The code I wrote is below. Where I am struggling is the program does not allow me to input age. Therefore, I cannot test if my temp for age works. It automatically defaults to 0 because it hasn't taken input. Here is my code:
// Program Title: Person function // Program Description: The program prompts the user for first and last name and age. // It then prints the output that was provided by the user.
#include<iostream> #include<string> using namespace std; class Person {
I am unable to implement the insert function properly, every time i run the program i just get the first value and name, I am not getting other Id's and name.
"(Header File)" #include <iostream> #include <string> using namespace std; class node{ public: int ID; string name; class node *left, *right, *parent;
This for loop replaces the stars ******** in an array that contains a word to be guessed with the correct letter (c) that the user inputs if the word contains that letter.
Problem: After every guess the same hidden string of stars ******* is displayed instead of ex: ***W**** (assuming W was entered by the user)
How can I update the old ******** string in the Stars array with the new string that includes the correct letters chosen, so after every correct guess at a letter in the word a new string is displayed including the correct letters chosen?
I'm pretty sure I have to use strcpy but not sure how to implement it using a loop.
Code: for(i = 0; i < strlen(unscrambledWord); i++) { if(unscrambledWord [i] == c) { Stars[i] = c; } }
In my code the cout phrase is supposed to give me an angle in degrees. no matter which 2 points i enter in, it always outputs the angle between them to be 57. This is because the acos value of 0 in degrees is 57. The program compiles without error.
Here is the code:
/* Synopsis: This program reads in the coordinates of two 2D vectors and outputs the angle between the vectors in degrees. */
#include <iostream> #include <iomanip> #include <cmath> using namespace std; // function prototypes // ENTER FUNCTION PROTOTYPE FOR normalize() HERE. void normalize(double & x, double & y);
I am currently trying to understand why this example for using an array as an argument in a function has a different result than what the lecture notes say it should be.
So supposedly sum should return with the value 28, but I get 27 no matter what. I also am not very good at reading and understanding what exactly the order of operations for this function are.
Code: #include <iostream> using namespace std;
int sum(const int array[], const int length) { long sum = 0; for (int i = 0; i < length; sum += array[++i]); return sum;
I am doing a written lab in my programming class in which we must write the output for three lines in a function. However, when I enter the code in my compiler I only get error messages. I was just wondering what the outputs under snap, crackle and pop should be and why.
#include <iostream> using namespace std; void snap (int i, int j); void crackle (int &a, int &B)/>; void pop (int &e, int f); int main () { int i = 1, j = 2;
Finally got to functions. Made a simple one that adds two numbers:
Code: int add(int a, int b){ cout<<"a+b="; return a+b; }
It refuses to give an output unless I use cout.
If I just call the function like so: "add(12, 24);", shouldn't it print out a+b=36? It only prints out "a+b=", unless I use "cout<<" ahead of the call.
My simple question is why does it need cout ahead of the call? Shouldn't "return" do its job and print out the number?
I have written a function that takes in a positive decimal and returns its Binary equivalent; however, the output always adds an additional zero to the binary. What could I do to get rid of it?
If the number is 7, it outputs 0111 instead of 111.
I want to create a function that will accept input from the user and return the input, to be used for further calculation. I know how to accept and return with integers as parameters , but how do i do it with arrays?
Suppose there is an array of numbers arr[]. Now, i want a function that accepts the input from the user, and return the array for further manipulation.
For example, if the array is arr[5], then i should call a function and accept the values from the user. Then, i should return the imputed values and print the same. How can i do this.
I have to convert a binary value from an input file (the name of which is given by the user) and then convert the binary to decimal value and print that in an output file.
Right now it is compiling just fine with no error messages, but when I run the program, it doesn't end or print to the output file.
Code: #include <iostream> int multiply (double x, double y) { double result = x*y; return (result);
[Code] ....
I get the answer 5.94 (which is what I'm looking for). I can't work out why the first example is not outputting a decimal number. I have set the variables as a double so I just can't see why this is not working for me.