0
IM A NOOB I NEED HELP WITH MY CODE PLS ANYONE HELP ME :'))))
So i wanted to make a program in which if i input N=5, output will be -5,-4,-3,-2,-1 if i input N=100, output will be -100,-99,-98,-97,.....-2,-1 Here's the code i used : -------------------------------------------- #include <stdio.h> #include <stdlib.h> int main() { int i,N; scanf("%d",N); i=N*(-1); printf("%d",i); if(i<(-1)) { i=i+1; printf("%d",i); } return 0; } -------------------------------------------- but it didnt work :( whats wrong with my code, can anyone tell me? I don't want to use the "for" function here, thank you
2 Answers
+ 3
You need to use a loop or function recusion to repeat tasks. I would also suggest linking the code instead of copy and pasting it as it is easier for us to help you and theres no character limit.
Loop example: https://code.sololearn.com/cWqaQr5gT93P/?ref=app
+ 2
recursion. If you don't want to use for loop.
https://code.sololearn.com/cJwygE6QEoxh/?ref=app