Posts
 
Reputation
Joined
Last Seen
Ranked #2K
Strength to Increase Rep
+0
Strength to Decrease Rep
-0
100% Quality Score
Upvotes Received
2
Posts with Upvotes
2
Upvoting Members
2
Downvotes Received
0
Posts with Downvotes
0
Downvoting Members
0
2 Commented Posts
0 Endorsements
Ranked #2K
~16.7K People Reached
About Me

I am an old man who is interested in, among other things, computer programming and mathematical applications of computers in particular.

Interests
Music, astronomy
PC Specs
GATEWAY WITH amd ATHLON cpu, WINDOWS 98
Favorite Tags
c++ x 42
c x 11

39 Posted Topics

Member Avatar for mariners95

[QUOTE=Narue]If it's a square matrix then you can do it with something like this: [code] for (int i = 0; i < 4; i++) { for (int j = i + 1; j < 4; j++) { int save = matrix[i][j]; matrix[i][j] = matrix[j][i]; matrix[j][i] = save; } } [/code] …

Member Avatar for johnnew
0
400
Member Avatar for Cup of Squirrel

I've been following this thread and I also downloaded the Bloodshed compiler. Can you tell me where that online tutorial is?

Member Avatar for mslade
1
2K
Member Avatar for nsavvinv

[QUOTE=nsavvinv]Hi everybody, is there a simple way to print a floating point number in its internal representation (i.e. binary or hex) in C(C++)? Yet another question -- is there a linux utility to do the opposite thing with a binary file (i.e. choose a range of bits and convert it …

Member Avatar for frodothehobbit
0
6K
Member Avatar for 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 <iostream.h> class secret { friend class not; private : int a; …

Member Avatar for Abivino
0
127
Member Avatar for mus_203

[QUOTE=mus_203]Hi I have a little question which I have partly tried but I am not completely sure if I am doing it correctly. Heres the question Does the equation 2x=26(mod32) have any solutions? If it does determine them and if not then explain why. Down below is how I approached …

Member Avatar for thoughtcoder
0
113
Member Avatar for blackdove
Member Avatar for dark7angelx07

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..., skipping every other integer. The reason that this works is once …

Member Avatar for DavidB
0
1K
Member Avatar for theoddmonkey

[QUOTE=theoddmonkey]I have two snippets of code that I am having a lot of trouble with finding the closed form Summations and time complexities for: x=0; for(i=1;i< pow(2,N); i = 2*i + 2){ for(j=1;j<N ; j++){ x=x+j; } } and: x=0; for(i=1;i <= (2*n); i++){ for(j=1; j <= n; j++){ if(j<i) …

Member Avatar for swati poddar
0
79
Member Avatar for murschech

I have downloaded the free Borland compiler Bcc32 and am delighted with it. I also downloaded the turbo debugger. I have a lot of experience using a debugger from an integrated environment but the Borland download includes only the command line version of the compiler and I don'y know how …

Member Avatar for bdj
0
591
Member Avatar for killerdrummer2

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 computer were to give you a 20 decimal digit answer the last few digits …

Member Avatar for murschech
0
189
Member Avatar for 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 when we programmed in C rather than C++ the same problem occurred …

Member Avatar for Ravalon
1
160
Member Avatar for dannyfang

[QUOTE=1o0oBhP]whilst we're on the subject is there a lib function for integer to string ect....[/QUOTE] Yes. itoa is the name of the function. There are corresponding functions for long or double to string. Here's an example. [code] #include <stdlib.h> #include <iostream.h> main() { int val; char st[10] val = 5 …

Member Avatar for Dave Sinkula
0
333
Member Avatar for 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. [code] #include <iostream> using namespace std; bool divides(int,int); main() { int a,b; char ch; cout << "Enter a then b: …

Member Avatar for jwenting
0
105
Member Avatar for Niklas

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 you expect it to do something after you enter a. What it's …

Member Avatar for Niklas
0
255
Member Avatar for 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 variable by the same name (even from functions compiled separately) are references to the same thing." Here's an …

Member Avatar for Dave Sinkula
0
146
Member Avatar for jazzyjoe

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) ) so what you need to do is have another variable, say sum2, which, like sum, …

Member Avatar for murschech
0
147
Member Avatar for mina1984

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 divisor of j and k or not. Here's how to do that: …

Member Avatar for mina1984
0
391
Member Avatar for 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 application in mind, but this simple example makes the point.) What I really want to do is replace …

Member Avatar for Dave Sinkula
0
218
Member Avatar for feda

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 to see whether the i numbers a, a^2, a^3...a^i are …

Member Avatar for murschech
0
212
Member Avatar for Potsuki

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 it out by making up a data set and try carrying out the exact program …

Member Avatar for murschech
0
185
Member Avatar for hopeolicious

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).

Member Avatar for murschech
0
125
Member Avatar for koolguysj

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 surprised that the compiler let you get away with the statement "anwer = *cnr". The initial value of …

Member Avatar for murschech
0
401
Member Avatar for tat2dlady

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). If there's a more elementary way to do this problem I'd like to know about it. …

Member Avatar for murschech
0
155
Member Avatar for Foxtildawn

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 = 32*0.669572, so the exponent is 5 and the significand is .669572. You've got to …

Member Avatar for murschech
0
61
Member Avatar for higherGround574

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 think) if x is not on the list and also if x = a(n-1). The number …

Member Avatar for higherGround574
0
270
Member Avatar for tonja1196

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 parametr list. You can't do this successfully unless you make them reference variables. (i.e., just …

Member Avatar for prog-bman
-1
116
Member Avatar for ohnbabygal

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?

Member Avatar for Dave Sinkula
0
111
Member Avatar for Lapari

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 you make the variables public?) 2: You use the word "void" to indicate no arguments, as in …

Member Avatar for murschech
0
111
Member Avatar for Asif_NSU

[QUOTE=Asif_NSU]After having us write codes to convert decimal numbers to another base my faculty has now asked me to write codes to convert a number from ANY base to another. He explains that itz simple since i already wrote the program to convert integer to another base. So i just …

Member Avatar for Asif_NSU
0
207
Member Avatar for fopah

[QUOTE=fopah]i am trying to make a program that displays to the screen the prime factors of a given number. i have it all the way to the prime number checking i dont quite understand how to extract the prime numbers any help would be much appreciated[/QUOTE] I'm not sure I …

Member Avatar for Asif_NSU
0
350
Member Avatar for seeplusplus

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 } and the other (the default) would be rational() { num = 0; den = 1; } In order to …

Member Avatar for Dave Sinkula
0
88
Member Avatar for Guppy25

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 fraction 3.0/4.0 where you really want 3/4. Attached is a simple fraction program. (It …

Member Avatar for murschech
0
142
Member Avatar for akila

[QUOTE=akila]I have a simple program to figure out the single machine precision (epsilon). According to C, float precision is 1.2e-8, but I'm getting the double precision, 2.2e-16. I can't figure out how else to force single precision? [code] void main(void) { float eps = 1.0f; while( eps + 1.0f != …

Member Avatar for murschech
0
153
Member Avatar for crq

[QUOTE=jwenting]headerfiles are not compiled, clear and simple. .o files are compiled compilation units which have not yet been linked, header files are not compilation units.[/QUOTE] That's my understanding too, but a couple of weeks ago I asked a question in this forum about a header file like this: [code] // …

Member Avatar for Dave Sinkula
0
160
Member Avatar for compeat

[QUOTE=Asif_NSU]well dont know much about C++ standards, but this is what was written in page no 193, The C programming Language(second edition) by K & R: So i think in C the type of integral constants are very much defined. U might want to go here [url]http://www.lysator.liu.se/c/schildt.html[/url] and see section …

Member Avatar for Dave Sinkula
0
562
Member Avatar for harshchandra

In the first case the outer loop (i loop) repeats N times and for each repeat of the outer loop (i loop) the inner loop repeats N times. As you wrote this program, the k loop runs once, having nothing to do with i or j, so whatever the loop …

Member Avatar for murschech
0
134
Member Avatar for Guppy25

When you get your program running your in for another surprise. Your program will say, for instance, that 3/5 = 0. The problem is that onefraction.num and onefraction.den are integrs and when you divide integers you just get their integer quotient. Something like this will work: decimal = (1.0*onefraction.num)/onefraction.den;, or …

Member Avatar for murschech
0
123
Member Avatar for zack_rage

If you're using the installation instructions that Borland supplies you might have been led astray by the statement that tells you to put into the config file the line. -I"c:\Borland... That first letter, upper case I, looks very much like lower case l in the font Borland uses. That error …

Member Avatar for murschech
0
101
Member Avatar for murschech

I've seen a number of listings which include some pre-proccessor stuff that I don't see the need for. Here's an example. The file is a header file ADD.H. Here is the whole file: ___________________________________________________________________ #ifndef ADD_H #define ADD_H (Some function prototype which is just what you'd expect in a header …

Member Avatar for Dave Sinkula
0
109

The End.