Search Results

Showing results 1 to 40 of 60
Search took 0.01 seconds.
Search: Posts Made By: murschech
Forum: C++ Jan 15th, 2007
Replies: 3
Views: 2,530
Posted By murschech
Good for your compiler! The stored value of a floating point number has a limited precision, probably 50 or 60 bits. This is equivalent to a certain number of decimal digits, say about 15. If the...
Forum: C++ Jan 7th, 2007
Replies: 17
Views: 2,292
Posted By murschech
So what's a poor programmer to do? Since it's apparently not possinble to know when this troubelsome newline char will appear would you recommend that cin.ignore() be used before any call to cin >>?...
Forum: C++ Jan 6th, 2007
Replies: 17
Views: 2,292
Posted By murschech
Thanks for the explanation. I still have a question. Now I can't see why the
little program below works.

#include <iostream>
using namespace std;

main()
{ int x,y;
cout << "Enter x:...
Forum: C++ Jan 1st, 2007
Replies: 17
Views: 2,292
Posted By murschech
In using "cin" for getting input I have about a 99% success rate. In the remaining
1% of cases the program does not pause for input. What causes this and how does one fix it?

In ancient times...
Forum: C++ Feb 10th, 2006
Replies: 2
Views: 1,583
Posted By murschech
Calling all Dev_C++ users,

Here's a mystery! The following little program, which determines whether one integer is a divisor of another or not, compiles and runs fine using Borland's bcc32.

...
Forum: C++ Sep 20th, 2005
Replies: 10
Views: 2,391
Posted By murschech
I ran it and it works ok. In response to the prompt you enter a, then a space, then b, then a carriage return. You can also respond a, carriage return, b, carriage return. Your comments indicate that...
Forum: C++ Jul 28th, 2005
Replies: 1
Views: 7,434
Posted By murschech
I have a question on external variables in a multifile program.
Quoting from K&R (first addition, page 72)

"By default, external variables are also "global", so that all references to such a...
Forum: C++ Jul 6th, 2005
Replies: 2
Views: 7,298
Posted By murschech
You seem to have computed the average correctly. The most efficient way to compute the standard deviation is to use the formula

st. dev. = sqrt( (sum of squares -ct*square of av)/(ct - 1) )
...
Forum: C++ Jul 3rd, 2005
Replies: 10
Views: 17,747
Posted By murschech
I think I've already answered this but I'll do it in more detail.

x is divisible by i if the remainder when x is divided by i is 0, that is, x is divisible by i if and only if x%i == 0. Likewise,...
Forum: C++ Jul 1st, 2005
Replies: 10
Views: 17,747
Posted By murschech
The original posting (minah1984) seems to be using the definition of gcd to find the gcd. That's not a bad idea. The one thing missing is that he/she doesn't know how to tell whether i is a common...
Forum: C++ Jul 1st, 2005
Replies: 20
Views: 23,626
Posted By murschech
Your program doesn't make use of the efficiencies I mentioned. For one thing, you test possible factors up to valuex/2 but you only have to go up to sqrt(valuex), which is much smaller. (For example,...
Forum: C++ Jul 1st, 2005
Replies: 20
Views: 23,626
Posted By murschech
Someone commented that to see if n is a prime you only have to check possible divisors < sqrt(n). In addition, you can decrease the computing time a lot by testing the divisor 2 , then 3, 5, 7...,...
Forum: C++ Jun 30th, 2005
Replies: 3
Views: 4,533
Posted By murschech
Thanks a lot! Your program works fine and it tells me just what I need to know. I thought that I'd have to say in the declaration of F that *f is a function of two variables and I didn't know how to...
Forum: C++ Jun 30th, 2005
Replies: 3
Views: 4,533
Posted By murschech
Attached is a tiny program in which the function F has as an argument the function pointer double (*f) (double). F returns the sum f(1)+f(2)+f(3)+f(4).
(Naturally, I have a much more interesting...
Forum: C++ May 31st, 2005
Replies: 2
Views: 1,777
Posted By murschech
There are a number of problems with your program. The main one is that, while it prints out a lot of stuff that you don't need to see, it never performs the tests it's supposed to. Where do you test...
Forum: Computer Science Apr 27th, 2005
Replies: 2
Views: 5,759
Posted By murschech
I think that your "pseudocode" suffers from imprecision. If you tried to turn it into code in some language that you know (C, Pascal, Basic, or whatever) you'd see the problem. You could also check...
Forum: C++ Apr 20th, 2005
Replies: 2
Views: 3,040
Posted By murschech
Might it be that "employees" is ambiguous? It's both the name of the an array of integers and it's also a type that you've defined. (struct employees).
Forum: C Apr 4th, 2005
Replies: 3
Views: 6,438
Posted By murschech
One problem is that you'r not correctly initializing the variables in calcCNR. The last variable is where the result appears. When you call the function this variable has no significant value. I'm...
Forum: C Mar 23rd, 2005
Replies: 1
Views: 2,237
Posted By murschech
Here's an idea for how to partially solve the problem. I'm assuming that this is not for a first course in programming or CS. Specifically, I'm assuming you've studied trees (not just binary trees)....
Forum: C++ Mar 20th, 2005
Replies: 11
Views: 22,737
Posted By murschech
I've been following this thread and I also downloaded the Bloodshed compiler. Can you tell me where that online tutorial is?
Forum: Computer Science Mar 3rd, 2005
Replies: 1
Views: 4,242
Posted By murschech
I don't know what "unnormalized" means, but here's how to write it as a normalized floating pt. number: Since the smallest pwer of 2 bigger than the given number is 32, write it as
21.426304 =...
Forum: Computer Science Mar 2nd, 2005
Replies: 2
Views: 3,509
Posted By murschech
This looks like a variation on binary search. It divides the range a1..an into three equal pieces (roughly) and uses two comparisons to determine in which third x lies. The worst case occurs (I...
Forum: C++ Feb 23rd, 2005
Replies: 3
Views: 2,126
Posted By murschech
First, a tangential comment. Your function "addem" has a problem. You want the answers to appear in the variables na and da, so you'r asking the function to change the value of variables on the...
Forum: C++ Feb 22nd, 2005
Replies: 1
Views: 2,412
Posted By murschech
Here are a few observations.
1: Your class has only public members. You're probably supposed to make the variable members private. (This isn't required by C++, but what's the point of classes if...
Forum: C++ Feb 17th, 2005
Replies: 11
Views: 3,172
Posted By murschech
I have 2 questios.

1: what do the error messages say?
2: It looks to me like the whole program is turned into a comment! If not, whats the /* doing?
Forum: C++ Feb 17th, 2005
Replies: 11
Views: 6,516
Posted By murschech
Afew postings back I sent as an attachment a file called watch, which is a bare-boned program which would get you started. It doesn't do military time and it doesn't do the time difference. Have you...
Forum: C++ Feb 16th, 2005
Replies: 11
Views: 6,516
Posted By murschech
I think I see a couple of problems. For one thing, you can't have time difference as a member function. The reason is that the time difference is not determined by the data in the object. That is,...
Forum: C++ Feb 16th, 2005
Replies: 11
Views: 6,516
Posted By murschech
Time after 12:00 in seconds = seconds + 60*minutes + 3600*hours. (but 12 o'clock becomes 0). For example, at 2:23:50 PM the time that has elapsed since noon is 50+23*60+2*60*60 seconds.

When...
Forum: C++ Feb 16th, 2005
Replies: 11
Views: 6,516
Posted By murschech
Here's my contribution, on the attached file. I hope iit's of some use to you
Forum: C++ Feb 15th, 2005
Replies: 5
Views: 3,262
Posted By murschech
Your example of 6Z's in base 36 ought to work if you interpret it as an unsigned long integer. The value of this number is 36^6 -1, which is about 2 billion 176 million. which is well within the...
Forum: C Feb 15th, 2005
Replies: 11
Views: 24,695
Posted By murschech
Sorry. I didn't read your code carfully enough before I replied.
Forum: C Feb 15th, 2005
Replies: 11
Views: 24,695
Posted By murschech
Your program won't work. The reason is that when you write matrix[i][j] = matrix[j][i] you've lost the contents of matrix[i][j] forever and you can't get it back to put in position [[j][i]. This will...
Forum: C++ Feb 15th, 2005
Replies: 5
Views: 3,262
Posted By murschech
In order to change the basis you have to do arithmetic. For instance, if you're talking about integers, then the rightmost digit to base N is gotten by dividing the number by N and taking the...
Forum: C++ Feb 8th, 2005
Replies: 2
Views: 5,644
Posted By murschech
Thank you.
Forum: C++ Feb 8th, 2005
Replies: 2
Views: 5,644
Posted By murschech
A rather old C++ book I have says that one class may be declared a friend class of a second, and then the first class can access the private data of the second. I tried this example
[code]
#include...
Forum: C Feb 8th, 2005
Replies: 5
Views: 3,271
Posted By murschech
I'm not sure I know what you mean by having it "all the way to prime number checking". I'll guess that you mean that you know how to check whether the given number is a prime or not. If you find that...
Forum: C++ Feb 7th, 2005
Replies: 2
Views: 3,063
Posted By murschech
For starters, you'll need 2 constructors. One will be something like

rational(int m, int n)
{ num = m;
den = n; //You really should check for n == 0
}
[\code]
and the other (the...
Forum: C++ Feb 6th, 2005
Replies: 2
Views: 4,952
Posted By murschech
You don't need a private function.. Here's a simple fraction class. I hope this works. The last time I tried attaching a file I didn't succeed.)
Forum: C++ Feb 6th, 2005
Replies: 2
Views: 4,952
Posted By murschech
You don't need a private function here. Also I don't think it's a good idea to make the numerator and denominator doubles. For one thing, they may not print out properly, i.e., you may have a...
Forum: C++ Jan 31st, 2005
Replies: 4
Views: 11,103
Posted By murschech
Here's a program that writes a float or double in the form 2^exp * mantissa, with the mantissa expanded in binary. IEEE specs might call for an offset of the exponent.


#include <iostream.h>
...
Showing results 1 to 40 of 60

 


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

©2003 - 2009 DaniWeb® LLC