Message from C, C++ discussions

November 2019

— Another thing. On while(S>100) should I put the "!"?

— 

It's an unary operator so ,IT WILL only work with one operand.
Here you can easily do while(S<100)
Instead of while(!S>100)
So and so

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

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

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