Search Results

Showing results 1 to 40 of 222
Search took 0.02 seconds.
Search: Posts Made By: firstPerson ; Forum: C++ and child forums
Forum: C++ 3 Days Ago
Replies: 3
Views: 135
Posted By firstPerson
TO expand x % 100 will give you the last 2 digits, and x % 1000 will
give you last 3 digits, and in general :

x % 10^n will give you the last n digits. IN the special case
where n = 0, the...
Forum: C++ 4 Days Ago
Replies: 13
Views: 241
Posted By firstPerson
This should work. However, your all of your function does not
necessarily return something. Also use code goes here[ /code]
[code]
// Purpose: Complete the program to allow the entering of 3...
Forum: C++ 4 Days Ago
Replies: 3
Views: 155
Posted By firstPerson
When printing a binary tree you can either print it in pre, mid, or post
order. I am not going to explain all of these. You should google them.

The usual way one would display a binary tree is by...
Forum: C++ 4 Days Ago
Replies: 13
Views: 241
Posted By firstPerson
You minXYZ and your maxXYZ function name should be :
FindMin and FindMax.

So replace the word minXYZ with FindMin and replace your maxXYZ with
FindMax.
Forum: C++ 4 Days Ago
Replies: 13
Views: 241
Posted By firstPerson
Your function prototype and your function definition are not the same.

You have

void Display(float AveXYZ, int maxXYZ, int minXYZ);
float ComputeAve(int x,int y,int z);
float FindMax(int x,...
Forum: C++ 4 Days Ago
Replies: 13
Views: 241
Posted By firstPerson
post your current code.
Forum: C++ 4 Days Ago
Replies: 6
Views: 218
Posted By firstPerson
Ouch, your logic is bad. You are killing your program slowly. Luckily it
fights back with the runtime exceptions.

Can you comment line by line so I see what your thinking process is.
That way...
Forum: C++ 4 Days Ago
Replies: 5
Views: 153
Posted By firstPerson
int main()
{
srand( time( 0 ) );

cout << rand() % 2 << endl;
}
Forum: C++ 4 Days Ago
Replies: 13
Views: 241
Posted By firstPerson
This function :

float Display(int x, int y, int z)
{
cout << "\tAverage= " << AveXYZ << endl;
cout << "\tMaximum= " << maxXYZ << endl;
cout << "\tMinimum= " << minXYZ << endl;

return 0;
}
Forum: C++ 4 Days Ago
Replies: 5
Views: 176
Posted By firstPerson
>>denominator = 1*2*...*k

I hope you know thats not valid. 1 * 2 * 3 ... k is called the factorial of K

So if K was 5, the the denominator will be 1 * 2 * 3 * 4 * 5.

So make a function : ...
Forum: C++ 5 Days Ago
Replies: 15
Solved: Easier Way?
Views: 261
Posted By firstPerson
Ouch. First off your code is not very readable. In fact there are statements
in your code that you probably think is doing something else than it does.

I think we need to take this step by step,...
Forum: C++ 6 Days Ago
Replies: 13
Views: 425
Posted By firstPerson
Ok then, some comments.

Where is ch declared in : ch == lower[i]

Why are you returning in a void function?


Make a toUpper fuction, that takes in a char and returns the upper cased of it.
...
Forum: C++ 6 Days Ago
Replies: 13
Views: 425
Posted By firstPerson
Use toupper (http://www.cplusplus.com/reference/clibrary/cctype/toupper/) function in cctype header file.
Forum: C++ 6 Days Ago
Replies: 7
Views: 202
Posted By firstPerson
I assume you call CheckTimer in a loop somewhere right?
Forum: C++ 8 Days Ago
Replies: 3
Views: 234
Posted By firstPerson
Can you use vectors instead of arrays?
Forum: C++ 8 Days Ago
Replies: 5
Views: 270
Posted By firstPerson
You don't have to manipulate the array after being sorted.

You can use a for loop to start from 1 to the array size to show the array. This would disclude the last element. Of course you need to...
Forum: C++ 10 Days Ago
Replies: 7
Views: 286
Posted By firstPerson
what is "it"?
Forum: C++ 10 Days Ago
Replies: 7
Views: 286
Posted By firstPerson
Is "it" a online judge? If so then post the question.
Forum: C++ 10 Days Ago
Replies: 7
Solved: memory leak
Views: 268
Posted By firstPerson
Ok then.

Here are some tips.

1) Whenever you have "new" keyword used, match it with a "delete"
keyword. Make sure there is a 1 to 1 relationship there.

2) Instead of raw pointers, use...
Forum: C++ 10 Days Ago
Replies: 7
Solved: memory leak
Views: 268
Posted By firstPerson
post your code and you will get more help
Forum: C++ 11 Days Ago
Replies: 3
Views: 197
Posted By firstPerson
using structs or classes would be easier and more elegant. What do
you think?
Forum: C++ 12 Days Ago
Replies: 17
Views: 491
Posted By firstPerson
This shouldn't be this hard.

You want to read from a text file of the format :

Firstname;Lastname;178

where the ';' means the word has ended. And you know you will
always read firstname,...
Forum: C++ 13 Days Ago
Replies: 5
Views: 211
Posted By firstPerson
>>This leaves my wondering if it would be possible to use -= to decrease after each loop in any way ?

Try it. Put Fr->callEvent -= Fr->callEvent after the call to Dt->eventHandler.
Forum: C++ 13 Days Ago
Replies: 5
Views: 211
Posted By firstPerson
>>Is there a way to delete the content on the left side of += after each loop ?

Can't know for sure without knowing Fr->callEvent type, but
Assumming callEvent is a string ? You can just reset...
Forum: C++ 14 Days Ago
Replies: 10
Views: 332
Posted By firstPerson
Change this :

if (num > largest)
largest = num;
count++;


to this :

if (num >= largest) {
Forum: C++ 14 Days Ago
Replies: 9
Views: 344
Posted By firstPerson
Don't worry about that. Just do it with if statements.

For example to sort 2 variable you can do this :

int n = 0;
int m = 0;
cin >> n >> m;

if(n < m )
cout << n << " " << m;
Forum: C++ 14 Days Ago
Replies: 7
Solved: Fstream help
Views: 318
Posted By firstPerson
Its not hard.

#include<fstream>
using namespace std;

int main()
{
ifstream readFromFile("test.txt");
string var1, var2;
readFromFile >> var1 >> var2 ;
Forum: C++ 14 Days Ago
Replies: 7
Solved: Fstream help
Views: 318
Posted By firstPerson
read this (http://www.cplusplus.com/doc/tutorial/files/)
Forum: C++ 14 Days Ago
Replies: 4
Views: 249
Posted By firstPerson
replace the && with the ||. You wan't the loop to run if either currentX OR currentY is not equal to toX or toY, respectively.

Also take out the

else { currentX-- } and else{ currentY-- }
...
Forum: C++ 18 Days Ago
Replies: 5
Views: 234
Posted By firstPerson
How to use functions :

1) Declare a prototype .

Ex :

//int is the return type
//calculateBonus is the function's name
//int number is its argument
// the semicolon " ; " means its a...
Forum: C++ 18 Days Ago
Replies: 9
Views: 344
Posted By firstPerson
Yep I guess, you can use if statements to sort this.
Forum: C++ 19 Days Ago
Replies: 25
Views: 1,421
Posted By firstPerson
What have you really learned in the class so far, what concepts?

You haven't learned about functions or you don't want to use functions?

Can you use the standard functions?

Think of all...
Forum: C++ 19 Days Ago
Replies: 25
Views: 1,421
Posted By firstPerson
In psuedocode of course :


void insertionSort(int * Array, int size)
{

//declare minElem variable to 0

//for i = 0 to i < size, increment i by 1
{
Forum: C++ 19 Days Ago
Replies: 25
Views: 1,421
Posted By firstPerson
well since since there are 5! possible combination, the minimum
number of if stated you will use is 2^5 = 32.

That will suck.

Just use insertion sort, the idea behind it is to mid a max*...
Forum: C++ 20 Days Ago
Replies: 25
Views: 1,421
Posted By firstPerson
Yes, your if/else is incorrect, only 1 of them gets evaluated.
Forum: C++ 21 Days Ago
Replies: 2
Views: 240
Posted By firstPerson
1) use Code tags.

2) The second one. Its more reusable.
Forum: C++ 22 Days Ago
Replies: 7
Solved: Warning help
Views: 282
Posted By firstPerson
>> but my teacher wants the user to be able to be able to input a number of any length

That means that you shouldn't use int, double , long long or whatever.
It means you should get your input as...
Forum: C++ 22 Days Ago
Replies: 7
Solved: Warning help
Views: 282
Posted By firstPerson
in your reverse function, what happens if num is less than 0?
What would the function return?

Get the input as a string and print the string backwards. Makes sure the string contains numeric data...
Forum: C++ 23 Days Ago
Replies: 3
Views: 322
Posted By firstPerson
Have a test condition in your for loop.

In psuedocode :


for i = 0 untill MAX{
pick1 = random number
pick2 = random number
while(pick2 == pick1 ) pick2 = another random number
pick3 =...
Forum: C++ 23 Days Ago
Replies: 4
Solved: Array functions
Views: 397
Posted By firstPerson
They have given you the answer, but let me expand on that :

Your prototype for fillArray is this :
int fillArray(int);//Trying to make a fn that fills an array

What does that mean ? It says...
Showing results 1 to 40 of 222

 


About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC