|
C++
Sept 26, 2010 3:09:57 GMT -5
Post by thepianist on Sept 26, 2010 3:09:57 GMT -5
Thanks guys. They both compile and run. I'll study them later. Horo I get 10 warnings: g:\pw\lab31.c(22) : warning C4244: 'function' : conversion from 'double ' to 'int ', possible loss of data g:\pw\lab31.c(25) : warning C4244: 'function' : conversion from 'double ' to 'int ', possible loss of data g:\pw\lab31.c(28) : warning C4244: 'function' : conversion from 'double ' to 'int ', possible loss of data g:\pw\lab31.c(31) : warning C4244: 'function' : conversion from 'double ' to 'int ', possible loss of data g:\pw\lab31.c(34) : warning C4244: 'function' : conversion from 'double ' to 'int ', possible loss of data g:\pw\lab31.c(22) : warning C4761: integral size mismatch in argument; conversion supplied g:\pw\lab31.c(25) : warning C4761: integral size mismatch in argument; conversion supplied g:\pw\lab31.c(28) : warning C4761: integral size mismatch in argument; conversion supplied g:\pw\lab31.c(31) : warning C4761: integral size mismatch in argument; conversion supplied g:\pw\lab31.c(34) : warning C4761: integral size mismatch in argument; conversion supplied That might be because you are using VS 6, which is pre-C99 as we discussed above. I get no warnings when I invoke the -w option with gcc in the terminal (Mac OS 10.6.4, so it's a BSD Unix system basically). All of my datatypes are doubles anyway, and I don't think any should be cast to int. Maybe gerg can shed some light. PS — you might look into something newer for your coding, like CYGWIN (complete Unix environment for Windows) or a newer version of visual studio. Even Bloodshed Dev C++ (despite not being developed since 2005) will give better results with C99 compliant source code.
|
|
|
C++
Sept 26, 2010 5:45:46 GMT -5
Post by keyboardclass on Sept 26, 2010 5:45:46 GMT -5
No sweat. I don't think I'm gonna be able to keep up with this thread. There was a time when I ran a classroom with a Novell network of 17 computers with midi keyboards. It was very much in my interest to write little programs for the students as part of their curriculum. I'm out of that now so not sure how much I'm into programming these days. Still, if it gets interesting...
|
|
|
C++
Sept 26, 2010 18:04:45 GMT -5
Post by thepianist on Sept 26, 2010 18:04:45 GMT -5
Me neither if gerg keeps reworking my labs for me. ;D Actually I appreciate it. BTW gerg, my lab as I wrote exits the loop by a false input (e.g. 0). What would be a more elegant way to exit the loop? I gather this has to do with standard I/O, but exactly what to do is beyond me.
|
|
|
C++
Sept 26, 2010 18:16:07 GMT -5
Post by thepianist on Sept 26, 2010 18:16:07 GMT -5
BTW gerg, your program gives me a number of warnings.
|
|
|
C++
Sept 27, 2010 0:19:26 GMT -5
Post by gerg on Sept 27, 2010 0:19:26 GMT -5
Sorry about the warnings. I got zero warnings, but then I don't have an ANSI C available, nor the time to look for one. Too much other work to do!
Exiting the loop: One thing I noticed is you had the input prompt (the scanf) twice. You don't need it. You can do a do..while, providing you check to make sure there was input before doing further processing. In the one I sent, this was the scanf followed by if.
Don't disparage those older books you mentioned. Much wisdom is there for the taking. The platforms may be outdated, but the axioms are not. A de facto standard textbook is Knuth's "The Art of Computer Programming", of which I've got the first three volumes.
|
|
|
C++
Sept 27, 2010 0:27:46 GMT -5
Post by gerg on Sept 27, 2010 0:27:46 GMT -5
keyboardclass:
Visual Studio 6 was great. Believe it or not, I still use it on rare occasions, to address customer problems retroactively in a software release from two major releases ago. Lightning quick compared to VS2005, 2008, or 2010.
|
|
|
C++
Sept 27, 2010 1:20:44 GMT -5
Post by thepianist on Sept 27, 2010 1:20:44 GMT -5
Sorry about the warnings. I got zero warnings, but then I don't have an ANSI C available, nor the time to look for one. Too much other work to do! Exiting the loop: One thing I noticed is you had the input prompt (the scanf) twice. You don't need it. You can do a do..while, providing you check to make sure there was input before doing further processing. In the one I sent, this was the scanf followed by if. Don't disparage those older books you mentioned. Much wisdom is there for the taking. The platforms may be outdated, but the axioms are not. A de facto standard textbook is Knuth's "The Art of Computer Programming", of which I've got the first three volumes. Thanks! I'll look for that book. Unfortunately, the old book belonged to someone else and I had to return it. I mainly asked for my own benefit, as I cannot turn it in like that. Had to follow a specified algorithm. I'll experiment on my own.
|
|
|
C++
Sept 27, 2010 1:40:21 GMT -5
Post by keyboardclass on Sept 27, 2010 1:40:21 GMT -5
keyboardclass: Visual Studio 6 was great. Believe it or not, I still use it on rare occasions, to address customer problems retroactively in a software release from two major releases ago. Lightning quick compared to VS2005, 2008, or 2010. Yeh, no errors with that. I still have Dos 6 hanging around somewhere!
|
|
|
C++
Oct 9, 2010 23:28:04 GMT -5
Post by gerg on Oct 9, 2010 23:28:04 GMT -5
Sure hope your assignment went well for you, Horo.
Sorry I've not had much time to socialize lately. Lots going on, good things, but somewhat scary too.
KeyboardClass, I see the merits of the KISS concept confirmed time and again.
|
|
|
C++
Oct 13, 2010 2:50:51 GMT -5
Post by thepianist on Oct 13, 2010 2:50:51 GMT -5
Yea, I got 100.
|
|