Why this programm doesn't work?

+2 votes
asked Nov 13, 2019 by Anton
#include <stdio.h>
#include <math.h>
int
main ()
{
  
int n, i, c,s, b,a,r=0;
scanf ("%d %d", &a, &n);
s=s+a;
for (i=0; i<=n; i++)
{
    b=10*r;
c=a*b;
s=s+c;
    r++ ;
}
printf ("%d", s);
return 0;
}

14 Answers

0 votes
answered Jan 8 by Suryateja Koka (140 points)
it is properly working

give a printf to help others to know entering values
0 votes
answered Jan 14 by Chandra Sagar (260 points)
yes it is working right once go through again
0 votes
answered Jan 24 by anonymous
it's running perfectly. All you need is to declare s=0.
0 votes
answered Jan 25 by anonymous
because you should initiate the value of s=0 while declaring variable so variable s can not store the garbage value.
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...