0
/*
ques: print the numbers from 0 to n, if n is given by the user.
*/

#include <stdio.h>
#include <math.h>

int main()
{
    
    int x;

    printf("enter the value you want to print, till from 1 : ");

    scanf("%d \n", x);

    for (int i = 0; i <= x; i++)
    {
        printf("%d \n", i);
    }

    return 0;
}

I actually wanted to do as per the requirement of the question but it is not printing the first statement.

Can anyone tell me why?

chux - Reinstate Monica
  • 143,097
  • 13
  • 135
  • 256
  • 4
    Ajinkya Jaipurkar Save time, enable all warnings to quickly report a problem with `scanf("%d \n", x);`. – chux - Reinstate Monica Apr 07 '22 at 06:21
  • 3
    Check out [What compiler options are recommended for beginners learning C?](https://software.codidact.com/posts/282565) That way you don't have to waste time chasing bugs that the compiler has already found. – Lundin Apr 07 '22 at 06:29

0 Answers0