Recent content by cmpeters

  1. C

    Problem with types in C

    I changed the casting mistake and now I can enter 4,294,967,295 and get a proper output. Thanks for the sample code. I will play around with it. We briefly discussed strings and c-strings. Then pointers and arrays. My professor doesn't give many practical examples or explanations...
  2. C

    Problem with types in C

    So should it be... temp1 = (int) (inValue/pow(10,length));
  3. C

    Problem with types in C

    Sorry, its a Solaris server and the compiler is gcc-3.2.3. If I input 2147483647 the program outputs the proper information. If I input 2147483648 I get 1-21-11-41-71-41-81-31-61-41-8 , which is wrong... all the way up to 4,294,967,295 which gives me 901-1. The outputs past the limit...
  4. C

    Problem with types in C

    I wrote the following code to convert a number into a "look and say" value. Everything works properly except for one thing. I cannot enter an integer value greater than 2,147,483,647 (the maximum long int). However, I'm expecting an input upto the maximum value of unsigned long int which is...
  5. C

    Online C/C++ Reference

    I was thinking that knowing the number of digits in the input integer would be useful to know, because then I would know how long to iterate a loop. Not sure if its necessary though.
  6. C

    Online C/C++ Reference

    Thanks, I'll read that thread. I have to write my programs to compile on a Solaris server with gcc. Not sure what version of Solaris or gcc they have. The input value from the user has to be a non-negative integer that can be as large as the maximum value of type unsigned long available...
  7. C

    Online C/C++ Reference

    I just realized that I'm confusing strings with arrays. I'm thinking that I should put the input integer into an array. What I need to do is compare each digit of the integer with the preceeding digits.
  8. C

    Online C/C++ Reference

    Does anyone know a website that has a good and thorough reference of standard functions and libraries in C/C++? Or a good suggestion for a reference book? Currently I have "Absolute Beginners Guide to C" but it doesn't seem very good. The majority of the books content has been discussed in...
  9. C

    C calculator help

    This is what I have for my semi-final code. Any comments or criticisms? #include <stdio.h> int main(void) { int exec = 1; float sum = 0, num; char oper; printf("\nBegin Calculations \n"); while(exec == 1){ scanf("%f %c", &num, &oper); switch(oper){...
  10. C

    C calculator help

    I figured it out. I moved the printf("End of Calculations"); outside of the loop. This might seem annoying, posting questions and then answering my own questions, but talking about this has really helped me see what's wrong with my code.
  11. C

    C calculator help

    Oh, ok. Is there a way to change that, or is it a fault in the way I'm approaching the problem? I guess I could do a printf after each case instead of outside of the switch, but is that considered proper?
  12. C

    C calculator help

    Another question. Does it make more sense to create a separate function to do the match calculations? Then call the funcation in a loop? /] #include <stdio.h> /* function prototypes */ float calcSum(float num, char oper, float sum); int main(void) { float sum=0, num; char...
  13. C

    C calculator help

    Oh wow, thanks. It makes sense to put the break; after the if/else statement. Another thing I noticed; when exiting the program I get the output "= number" twice. Begin Calculations 4 S = 4.000000 0 E = 4.000000 End of Calculations = 4.000000 When the user enters "E" I set the...
  14. C

    C calculator help

    Ok, so I played around with my program and removed the if/else statement from my switch and now the program partially works. It will not detect and prevent division by zero. Are if/else statements allowed within a case of a switch?
  15. C

    C calculator help

    How do i keep formatting in my post? The code I entered was a lot easier to read that what it looks like in my post. I read the rules about posting homework help, i'm not looking for an answer, just a point in the right direction.
Back
Top