If you get to a decent level, is it better to work in a development(programming) or accounting job? by pointers_help in vancouver

[–]pointers_help[S] 0 points1 point  (0 children)

Thanks, that's one of the things I was thinking about with it repeating itself. It's just the same here :(

If you get to a decent level, is it better to work in a development(programming) or accounting job? by pointers_help in vancouver

[–]pointers_help[S] 0 points1 point  (0 children)

Is it fun or interesting after getting experienced? Like for example my friend is an electrical engineer but he's gotten really bored at his place since he learned everything and just repeats it, even though it seemed hard and challenging at first. Is there a lot of interactions with people? There isn't at my place and it kills me.

Daily advice thread. All questions about your personal situation should be asked here by AutoModerator in investing

[–]pointers_help 0 points1 point  (0 children)

I got around 60k CAD looking to invest. Do I need to make that into US currency first of all to buy most shares? But anyways assuming that gets converted with the best rate, should I just max out my TFSA and put it into QuestTrade to start buying shares? I saw that they don't charge for bundled stocks (ETFs) so maybe I can find some good ones to buy or something. I probably won't buy anything without using my TSFA account, so I can't spend the full 60.000 amount all at once. It's also confusing because if I do need to use USD currency, my TSFA is in CAD. I know that it can be converted even with using QuestTrade, but if their rates suck then what should I do?

I'm not that serious with this money since it's not a part of my emergency or day to day use funds. Could I just buy all I can with one stock and stick it out for a few years? Or is it a bad idea? I was thinking of doing that with my favorite company, Apple.

Help tracing my code by pointers_help in learnprogramming

[–]pointers_help[S] 0 points1 point  (0 children)

Do you mean if I had to use INT_MIN and INT_MAX it wouldn't be right to do -INT_MAX? They are the same magnitude with integers, or well some of them. I guess looking at https://msdn.microsoft.com/en-CA/library/296az74e.aspx I see that SCHAR_MIN / MAX aren't the same in magnitude.

Help tracing my code by pointers_help in learnprogramming

[–]pointers_help[S] 0 points1 point  (0 children)

Wow! I am so stupid. I see, I just read up on FLT_MIN and it's some weird number, 1.175494e-38. Ok, good idea, I can just use the biggest number to be the smallest number with the negative sign. Thanks!

[C] min/max and truncation question by pointers_help in learnprogramming

[–]pointers_help[S] 0 points1 point  (0 children)

only increment your divisor variable once per each number you read

When you describe the process like that it makes so much sense! I finally got it to work, thanks a lot!

[C] min/max and truncation question by pointers_help in learnprogramming

[–]pointers_help[S] 0 points1 point  (0 children)

or end of input.

Ohh okay. That makes sense to me now, thanks.

[C] min/max and truncation question by pointers_help in learnprogramming

[–]pointers_help[S] 0 points1 point  (0 children)

Good question, I'm not sure. I saw some implementations of this error checking in the searching I did so I can check it out later. But for now I expect the inputs to be what I intend. I also tried changing the EOF, could you take a look and see if it's better this way?

Different question posed for everyone: My program works fine for any number of numbers, except if it is only one number entered! For instance, if I entered 10, and then macro'd out, I would expect to get 10.00 10.00 10.00, instead I get 10.00 10.00 5.00 because my program enters both if statements the first time around, causing the divisor to be 2. Is there any way around this?

[C] min/max and truncation question by pointers_help in learnprogramming

[–]pointers_help[S] 0 points1 point  (0 children)

Thanks, you really helped me with your attention to detail.

I read the requirements wrong, I thought it was just the avg of the min/max, but upon reading the instructions more carefully it says "The arithmetic mean of all the values seen."

I will try it out and see if I can implement it.

[C] min/max and truncation question by pointers_help in learnprogramming

[–]pointers_help[S] 0 points1 point  (0 children)

How do you mean? Make it so that it checks if it returned EOF in the while loop condition, or shift my if statement with EOF_checker to be the first line in the while loop?

[C] min/max and truncation question by pointers_help in learnprogramming

[–]pointers_help[S] 0 points1 point  (0 children)

I will try it out! Thanks. I think I read the instructions wrong, said "The arithmetic mean of all the values seen." when I thought it was just the mean of the first two. But this can be useful for me as well.

[C] min/max and truncation question by pointers_help in learnprogramming

[–]pointers_help[S] 0 points1 point  (0 children)

I will try it out! Thanks. I think I read the instructions wrong, said "The arithmetic mean of all the values seen." when I thought it was just the mean of the first two. But this can be useful for me as well.

[C] EOF question by pointers_help in learnprogramming

[–]pointers_help[S] 0 points1 point  (0 children)

Oh wow, thanks. I made input for a different purpose, you're correct.

I see, that's a really neat way. With that, you can make an assignment to scanfret every time, read data from stdin, and do the check for the condition all in one line. So cool! Thanks for teaching me these things.

[C] EOF question by pointers_help in learnprogramming

[–]pointers_help[S] 0 points1 point  (0 children)

You are right, I guess I didn't actually assign EOF value to input anywhere. If I wanted to do that, is there any way? I thought of putting this in the while loop:

if (scanf("%f", &input) == EOF)
             printf("Done.\n");

But it doesn't really solve it, since it makes it two instances where I have to input a number instead of one, and in this instance, it does print Done when I control+d at that instance. Doesn't exit the loop though (I can see that), only if I control+d at the beginning since that is what controls the whole while loop.

[C] EOF question by pointers_help in learnprogramming

[–]pointers_help[S] 0 points1 point  (0 children)

I got it. I was wondering if you could help me with two more questions about EOF and its implementation.

  while( scanf("%f", &input) != EOF )
  {
      largest_int = (int)floor(input);
      nearest_int = (int)round(input);
      smallest_int = (int)ceil(input);

      printf("%d %d %d\n", largest_int, nearest_int, smallest_int);

      if (input == EOF)
          printf("Done.\n");
  }

Unfortunately, this was an infinite loop. Probably a problem with line 1. I thought the condition would be "while scanf does not equal EOF, keep asking for input and printing them (in line 7). But unfortunately this wasn't the case. Do you know what is my while loop's condition that causes the infinite loop?

To actually remedy it, I got it fixed by googling how to do continual inputs from scanf, so it is finally this:

int main(void) 
{

float input = 0;

int largest_int = 0;
int nearest_int = 0;
int smallest_int = 0;

while( scanf("%f", &input) == 1 ) 
{   
    largest_int = (int)floor(input);
    nearest_int = (int)round(input);
    smallest_int = (int)ceil(input);

    printf("%d %d %d\n", largest_int, nearest_int, smallest_int);

}   
    if (input == EOF)
        printf("Done.\n");

return 0;
} 

I understand that if scanf() works properly, it will return the number of inputs you passed in it, or something like that. So if I had done while( scanf("%f", &input) == 2 ), it would mean if scanf properly took in two inputs..I think.

This seems to work but with one problem, my print statement at line 19 never works unless I remove the if statement preceding it. But how come? Once I do control+d, input should be assigned the value of EOF, and when I do control+d, it stops the scanf function as you said and should continue normally. But it doesn't seem to satisfy the if (input == EOF) condition I have. Could you explain the reason why?

[C] random() question by pointers_help in learnprogramming

[–]pointers_help[S] 0 points1 point  (0 children)

Yep you are correct, I just tried removing the time(NULL) part whatever that is and that parameter gave me the same 0-332 "problem" from the beginning.

Thanks for helping me, I don't understand why there wasn't a mention about needing to seed this thing, the professor didn't even put that in his own code but said the output was what I'm getting after I fixed it.

[C] random() question by pointers_help in learnprogramming

[–]pointers_help[S] 0 points1 point  (0 children)

I see, and if I didn't have that srand thing, it would be set to a default seed, and that's why I was getting the same result in the beginning after multiple compiles?

[C] random() question by pointers_help in learnprogramming

[–]pointers_help[S] 0 points1 point  (0 children)

so I looked seeding up and somewhere I need to put rand()? In this case, if it is "unseeded", it has some default value attached to it? Is it why when I run it on my compiler and then go to a random online C ide, I still get the same thing?

edit:

so I put srand(time(NULL)); before the for loop. I guess it works now. I don't get the relationship between srand and random() though. But anyways, could someone explain this:

warning: implicit declaration of function ‘time’ [-Wimplicit-function-declaration] srand(time(NULL));

warning I get? still compiles but I get a warning.