- Upvotes Received
- 2
- Posts with Upvotes
- 2
- Upvoting Members
- 2
- Downvotes Received
- 1
- Posts with Downvotes
- 1
- Downvoting Members
- 1
25 Posted Topics
Hello , i'm trying to solve a problem Tower of Hanoi recursively. I'm having problems with coming up with logic how to treat disks in terms of value. Lets say i have 3 disks how should i assign values to them ? My function is supposed to be defined such … | |
Re: youre problem is [CODE]# string Name; studentName(Name); [/CODE] you attempting to use Name variable without initializing it when you passing it to function. Also you should change void main to int main | |
Re: Hi, how can this condition to be ever true ? [CODE] cin << a; while(a < 0) [/CODE] | |
Re: Here's whats happening, you trying to store integer values in the variable choice everything is fine until the user enters a letter cin object goes into an error state and nothing gets stored in the variable choice. | |
Re: Do you get any run time errors ? I didn't go all over youre code but it seems that variable low hasn't been initialized. | |
Re: if you incluse <cctype> library you can use its functions like isupper() and islower() | |
Re: I haven't dealt with classes yet, but i would assume you'd have to place it inside the function. Have you tried ? | |
Re: Its just a matter of how you put them together, since they are separate variables you can just use third variable in the first of one and first in the place of third and same for the other two. | |
![]() | Re: what happens if string is uninitialized ? |
Re: [CODE]for(i>0;i<size;i++)[/CODE] i > 0 , first condition is initialization, since you do comparison it evaluates condition to false and sets i = 0; since 0 is not greater then 0. I assume you meant to do i = 0; | |
Re: This is something i came up with where it guesses in ten or less trys. [CODE] #include "stdafx.h" #include <iostream> #include <ctime> using std::cout; using std::endl; using std::cin; int high_low(int,int,int); int main() { srand(int(time(NULL))); int random = 1 + rand() % 1000; int guess = 1000, counter = 0; int … | |
Hi , i'm trying to do an exercise where the computer has to guess the random number from the range of 1-1000. Currently this is the way i have it set up as. I divide that range in half and store it in guess and then check it against the … | |
Re: look here temp= Index+1; shouldnt you be assigning a value from the array and not just a counter | |
Re: Hi, im new myself to the language, and haven't covered classes yet but by looking at the function PrintBoard shouldn't you want to pass it MyBoard array ? I would assume once function SizeBoard finishes execution MyBoard array gets destroyed and when you call PrintBoard it doesnt have anything. | |
| |
Re: why not use cin object as a test condition? That way it can get type mismatch and it won't write data to that type and we can easily get rid of bad input and ask user to reenter with proper data. Would this be a bad approach? | |
Re: line 84 you declared it but its not initialized to anything so when you get to line 87 it throws the error. you should replace grade with numAvg in switch | |
Re: just reset pwr to 1, since pwr never goes out of scope it holds the old value | |
Re: I think the problem might be on line 26 , array out of bounds ? Shouldn't it be < then | |
Hello, i'm reviewing the exercise from the book and trying to understand the point. Basically it creates a static array and declares uninitialized char pointer. Then it allocated memory dynamically to the same char pointer. What i don't understand why is the program using strcpy() to copy string into newly … | |
Hello , i was doing an exercise in book which asked to draw a diamond shape by displaying '*' using nested for loops. It took me quite a while to come up with a way to reverse the pyramid , and complete this exercise. So i was hoping some one … | |
Hi another exercise which im having problems with. In this challenge im given a four digit integer and encrypt each digit as follows. Replace each digit by the sum of that digit plus seven mod 10. Then swap 1st and 3rd digit places and 2nd with 4th. Heres what i … | |
Hello, Another exercise. In this particular problem we are given a five digit integer and program have to determine if its a Palindrome. Author states that we have to separate each digit into its own variables using % and /. I came up with solution but i don't know if … |
The End.