# Message from C, C++ discussions

November 2019

β βΊοΈπ

β

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);
}

β 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

β Oh, in the flow chart I forgot "Insert N" before "Insert V"

β And in the code I forgot "gets(N);" after "N, C, V, S = 0"

β Void main()
{
int N, C;
float V, S;
N=0, C=0, S = 0;

gets(V); /*(prefer it to input string,use scanf for INTEGER VALUES)*/

C = C+1;
if(V>0&&V<100) /*don't terminate if and for loop statements */
{
S=S+V;

}
printf("The sum is %d", S);
}

Message permanent page