Before seeing the solution make sure that you tried enough. Don’t paste the whole code, just find out the logic. If you stuck in trouble, just inform me on comment.
/**Bismillahir Rahmanir Rahim.**/
#include <stdio.h>
int main()
{
int a,b,c=0,x;
scanf("%d%d", &a, &b);
if(a<b)
{
for(x=a; x<=b; x++)
{
if(x%13==0) continue;
c+=x;
}
}
else if(a>b)
{
for(x=b; x<=a; x++)
{
if(x%13==0) continue;
c+=x;
}
}
printf("%d\n",c);
return 0;
}
#include
ReplyDeleteint main(){
int x,y,i,sum;
while (1)
{
scanf("%d\n%d",&x,&y);
for (i=x;i<=y;i++)
if(i%13!=0)
sum+=i;
printf("%d\n",sum);
}
return 0;
}
time limit error!!! why???