Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Why This Code Not Executing After enter the value?

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

int main(){
    int x;
    printf("Enter The Number :");
    scanf(" %d \n" , &x);
    int xS= sqrt(x);
    printf("Square Root of The Given Number : %d" , xS);
}

after entering the value 120 , nothing is happening! I am using Clion. What do I have to Do?

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

You should remove whitespace and '\n' from the format string of scanf.

An ‘\n’ or any whitespace character in the format string of scanf
consumes an entire sequence of whitespace characters in the input. So
the scanf only returns when it encounters the next non-whitespace
character, or the end of the input stream.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading