1 year ago

#385552

test-img

Ajinkya Jaipurkar

Why it is compiling it as an infinite loop instead for finite one?

/*
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?

c

function

printing

compiler-errors

c++17

0 Answers

Your Answer

Accepted video resources