why is it showing error


#1

https://www.codechef.com/problems/DWNLD

#include<stdio.h>
int main()
{
int t;
scanf("%d",&t);
while(t–)
{
int n,i,j=0,k;
scanf("%d%d",&n,&k);
int t[n],d[n];
for(i=0;i<n;i++)
scanf("%d%d",&t*,&d*);
for(i=0;i<n;i++)
{
if(k==0)
break;
j=j+t*;
if(j>k)
{
t*=t*-(j-k);
break;
}
else if(j==k)
{
t*=0;
break;
}
else t*=0;
}
int m=0;

for(i=0;i<n;i++)
{
    m=m+(t**d*);
}
printf("%d

",m);
}
return 0;
}


#2

okay, alright, first you should have formatted your code, but it’s fine, second are those double quotes in the code to point out where the errors are ? because I am confused by those alright, now let’s get to it, you have got for( int i = 0; i&lt ; n ; ++i ) in your second for loop, edit : welp…I know this is a problem, because there can only be two semicolons in the loop, besides, what is the purposeof n in there ? alright, that and in if( j => k ), this is wrong because there is no such expression in C, there are only >= so, the correct way ridiculous, but you need to write it would be if( j >= k ). Ok, as to why it is >= have newline, so instead of =>, is because of how printf( “%d”, m ), you need to add "
", and it is mentioned, which is “greater than or equal”, and not “equal or greater than” becomes printf( "%d
", m )


#3

#include<stdio.h>
int main()
{
int t;
scanf("%d",&t);
while(t–)
{
int n,i,j=0,k;
scanf("%d%d",&n,&k);
int t[n],d[n];
for(i=0;i<n;i++)
scanf("%d%d",&t*,&d*);
for(i=0;i<n;i++)
{
if(k==0)
break;
j=j+t*;
if(j>k)
{
t*=t*-(j-k);
break;
}
else if(j==k)
{
t*=0;
break;
}
else t*=0;
}
int m=0;

    for(i=0;i<n;i++)
    {
        m=m+(t**d*);
    }
    printf("%d

",m);
}
return 0;
}


#4

Please format your code using Ctrl + K and then insert your code in it.


#5

how can I format my code??? and there is no syntax error. My program is running fine in codechef ide. But I think I have missed some cases which is leading to the error…


#6

what do you mean exactly by format ? there are syntax error though, => instead of >=, and the fact that you put three semicolon( ; )s in the for loop


#7

P.s I put them in codechef ide and I got error


#8

ok see below codes… I think it will be ok…


#9

is the error mentioned wrong answer ?


#10

hmm, I think it is possible for one of the member of the array to become negative, not too sure