Tip : Try Yourself First . For Help Scroll Down.
Code:
#include<stdio.h>
int main()
{
int a,b,i,sum,t,l=1;
scanf("%d",&t);
while((t--)&&(t>=0 && t<=100))
{
int sum=0;
scanf("%d%d",&a,&b);
if(a>=0&&a<=b&&b<=100)
{
{
for(i=a;i<=b;i++)
{
if((i%2)!=0)
{
sum=sum+i;
}
}}
printf("Case %d: %d\n",l,sum);
l++;
}
}
return 0;
}
#include
ReplyDeleteint main(){
int tc,a,b,i,j,sum;
scanf("%d",&tc);
for (i=1;i<=tc;i++)
{
sum=0;
scanf("%d %d",&a,&b);
for(j=a;j<=b;j++)
{
if(j%2!=0)
sum=sum+j;
}
printf("Case %d: %d",i,sum);
}
return 0;
}
why i get WA in this code even it gives the correct output...pls tell me