Message from C, C++ discussions

November 2019

— Oh thanks!!! So (S>100) without the exclamation mark is ok too?

— 

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)

— 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

Message permanent page

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

main()
{
int N, C;
float V, S;
N, C, V, S = 0;
{
gets(V);
C = C+1;
if(0<V<100);
{
S=S+V
}
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.