##code is not running
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
your while loop is not doing what you want. Your while loop fixed:
while ( i <= t) {
scanf("%d", &N);
printf("%d\n", 2*N );
i = i+1;
}
Curly brackets are used to define code blocks. You not using them in your solution would be equivalent to this:
while ( i <= t) {
scanf("%d", &N);
}
printf("%d\n", 2*N );
i = i+1;
Which will cause an infinite loop for obvious reasons.
d_d26
July 7, 2023, 2:37pm
3
ohh I didnt notice i was missing the brackets. Thank you .