My issue
It is showing time limit exceed what to do now
My code
// Debug the given code
#include <stdio.h>
int main() {
int t;
int N;
int i = 1;
scanf("%d", &t );
while ( i <= t)
scanf("%d", &N);
printf("%d\n", 2*N );
i = i+1;
return 0;
}
Learning course: C for problem solving - 1
Problem Link: CodeChef: Practical coding for everyone
@rishiraj54123
Missing brackets in while loop might be causing this.
Here is my code;
// Debug the given code
#include <stdio.h>
int main()
{
int t;
int N;
int i = 1;
scanf("%d", &t );
while ( i <= t)
{
scanf("%d", &N);
printf("%d\n", 2*N );
i = i+1;
}
return 0;
}
1 Like
The problem is you have taken/initiated N only once but putting 3 values to it. Initialize the integer N inside the while loop. This is the logical error in the code and there are some brackets and semi-colons to be taken care of. Thank you!
1 Like
@swagatpati
You do not need 3 different variables to use 3 different values here tho. The while loop takes input for every iteration and keeps updating the value of N on which some operation is then performed.
It was done after refreshing several times 
