Search Results

Showing results 1 to 29 of 29
Search took 0.01 seconds.
Search: Posts Made By: darkagn ; Forum: C++ and child forums
Forum: C++ Apr 5th, 2008
Replies: 8
Views: 570
Posted By darkagn
You have two loops


for (i=0; i<n-1; i++)
{
for (j=0; j<n-1-i; j++)
{


but I can't see where you initialise n. Try printing the value of n to the console just before that line and see...
Forum: C++ Apr 5th, 2008
Replies: 8
Views: 570
Posted By darkagn
Yes, but to make your code easier to follow it might be worth writing "else if (choice==2)"...
Forum: C++ Apr 5th, 2008
Replies: 8
Views: 570
Posted By darkagn
if (choice==1)
{
//HERE CHOICE = 1
for (i=0; i<20; i++)
{
cout<<"\n"<<num[i]<<endl;
}
return 0;
}
// HERE CHOICE STILL EQUALS 1!
Forum: C++ Apr 4th, 2008
Replies: 7
Views: 782
Posted By darkagn
http://gcc.gnu.org/ is the official site for the gcc compiler. Latest version was released in March this year and is version 4.3.0. Note that it is actually a standard compiler that is usually...
Forum: C++ Apr 1st, 2008
Replies: 11
Views: 1,185
Posted By darkagn
It seems as though you've done everything up until this point. For this section you need to:


somehow prompt the user for some coordinates
use these coordinates to form some lines
sum the...
Forum: C++ Mar 12th, 2008
Replies: 20
Views: 2,789
Posted By darkagn
Sorry dougy83, you are correct, and thanks for helping my understanding. :)
Forum: C++ Mar 10th, 2008
Replies: 2
Views: 1,388
Posted By darkagn
You write it like this:

int main()
{
int x, y;
cin >> x;
cin >> y;
if (x==0 && y==0)
// the && means and, use || for or
{
Forum: C++ Mar 10th, 2008
Replies: 20
Views: 2,789
Posted By darkagn
You use const in this situation because the strings aren't going to change, you want them to remain constant.

The char * is an object type in C++ that literally means "pointer to char". The char...
Forum: C++ Dec 15th, 2007
Replies: 5
Views: 1,405
Posted By darkagn
I haven't used a mac for quite some time so I could be wrong, but don't most macs come with g++ these days? You can use it from your Console utility and should be a sufficient compiler for a starter...
Forum: C++ Dec 15th, 2007
Replies: 4
Views: 1,767
Posted By darkagn
One advantage of lists that I can think of is that it is often easier to rearrange the data in a list because you are working with pointers. That is, if you have a list of objects and you want to...
Forum: C++ Nov 30th, 2007
Replies: 7
Views: 7,968
Posted By darkagn
I'm pretty sure this should work:

char c;
cin >> c;

I haven't tried it, but it only allows for a one character input I think...
Forum: C++ Nov 15th, 2007
Replies: 5
Views: 1,044
Posted By darkagn
The first parameter tells you how long the first row (I guess this is the base of your pascal triangle perhaps?) is. The second parameter tells you how many rows there are (the height of your pascal...
Forum: C++ Nov 15th, 2007
Replies: 5
Views: 1,044
Posted By darkagn
Forum: C++ Nov 13th, 2007
Replies: 2
Views: 560
Posted By darkagn
I'm sure there's a more elegant solution but you could create an array where each element is the result of an OR result of the other two arrays.

for (int i=0; i<10; i++) {
array[i] = a[i] ||...
Forum: C++ Nov 13th, 2007
Replies: 7
Views: 944
Posted By darkagn
A couple of comments for you to consider:


You will need a variable of type float or double to store and print the average
You can use modulo arithmetic to get the digits of a number (%)

...
Forum: C++ Nov 13th, 2007
Replies: 5
Views: 604
Posted By darkagn
Try something like:

int total = 0;
for (int i=0;i<10;i++) {
total = a[i]+b[i]+c[i]+d[i]+e[i];
// print result
printf("total = "+total+"\n");
// print i to see which iteration of the loop...
Forum: C++ Nov 12th, 2007
Replies: 5
Views: 604
Posted By darkagn
Sorry, I don't understand your question. Do you mean How do you select the same element from a series of arrays and add them together?
Forum: C++ Sep 23rd, 2007
Replies: 4
Views: 839
Posted By darkagn
You have not declared your i before this line. An array needs its size set - you have done this correctly in your string array. You need to declare your i...
Forum: C++ Sep 23rd, 2007
Replies: 2
Views: 2,526
Posted By darkagn
In this thread (http://www.daniweb.com/forums/thread89711.html) I explain a similar question by example. It sounds like you need to describe the time complexity of this code in terms of k but I'll...
Forum: C++ Sep 22nd, 2007
Replies: 8
Views: 5,347
Posted By darkagn
The main difference between the while and do-while loops is that the condition in a while loop is checked before the inner code is executed, whereas the do-while loop's condition is checked after the...
Forum: C++ Sep 18th, 2007
Replies: 8
Views: 2,063
Posted By darkagn
I think you want hours as an int and minutes as a float.
Forum: C++ Aug 22nd, 2007
Replies: 18
Views: 1,798
Posted By darkagn
First, you need to loop until the input = "E". The prompts would work like this:

int lineNumber = 1;
cout << lineNumber << "> ";
cin >> temp;

This will prompt with the current line number....
Forum: C++ Aug 20th, 2007
Replies: 6
Views: 2,562
Posted By darkagn
Sorry there Ken JS. I'm struggling to remember this stuff but I thought that the parity check matrix was generally binary. Because your G is not in binary, I don't think you can apply (mod 2) to it,...
Forum: C++ Aug 20th, 2007
Replies: 10
Views: 1,527
Posted By darkagn
I stand corrected - apologies.
Forum: C++ Aug 20th, 2007
Replies: 10
Views: 1,527
Posted By darkagn
Yes dougy83 that is what i was getting at, but I didn't want to give away the answer. :P

Minor point: don't forget that in C++ you must initialise your variable outside the for loop:
int e;
for...
Forum: C++ Aug 20th, 2007
Replies: 10
Views: 1,527
Posted By darkagn
The statement e=e%2; will result in e being equal to the remainder of the division of e by 2. In other words, if e is even, e will become 0, if e is odd, e will become 1, and e will not change after...
Forum: C++ Aug 19th, 2007
Replies: 6
Views: 2,562
Posted By darkagn
In binary, -1=1, so -P^t=P^t. What you have done looks good to me, but maybe someone else can check for you also? It's a long time since I did this sort of thing...
Forum: C++ Aug 18th, 2007
Replies: 3
Views: 791
Posted By darkagn
Hi Laseredd,

That short program looks good! I think you have shown understanding of some very important C++ principles here, classes, methods, I/O. :)
As an extension, how do you think you would...
Forum: C++ Aug 17th, 2007
Replies: 5
Views: 592
Posted By darkagn
Don't do that. It is much better programming practice to separate functions where possible. Imagine if you had to call int Add (int x, int y) ten times with different variables for parameters? Or a...
Showing results 1 to 29 of 29

 


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

©2003 - 2009 DaniWeb® LLC