Message from C, C++ discussions

November 2019

— In simple words ,every function has a return type(Must have)
You can use either void(it doesn't return any value) or int(returns a value)

Message permanent page


Let's say you are using ! Which means NOT ,if I am right here to execute the while loop successfully.
Condition you are trying to get is,
While works till S is smaller than 100.

So you can simply write it S<100.
It will work just fine

— Thanks, Sid!

— ☺️👍

— Second program. I've wrote a flow chart. N is the number of values to insert, V the value you input, C the counter and S the sum.

int N, C;
float V, S;
N, C, V, S = 0;
C = C+1;
printf("The sum is %d", S);

Message permanent page

— Do the flow chart and the code have a sense? Sorry for bothering

— Why not calling the variables in a meaningful way?

— Call S sum, V inputValue etc etc

— Because that's how our teacher teaches us to define variables

— That's a wrong (imo) way to define variables. They don't create a readable code

— Tell him, then. I can't do nothing, but thank you for telling me this.

— I'm in the 4th year of scientific liceum (Italy) and we are still doing this. 3/4 of the class still don't understand this, and we've been doing algorithms, flow charts and pseudo-C since February-March (when we still were in the 3rd year...)

Message permanent page