 Hello friends. I am Sanjay Gupta. In this video, I am going to demonstrate you how you can read a number from user and another number from a file. Now you have to compare them using file handling in C programming. Before starting, you can note how you can search my YouTube channel. You can type my name Sanjay Gupta in YouTube search. My channel will be available there. You can watch various programming related videos there. So now I am implementing solution of this problem. So in this problem, I have to read two values, one from user, from output screen and another from a file. And I have to compare those numbers, whether they are equal or not. So for that purpose, I am including two header files. First is stdio.h and second one is stdlib.h. Now I am going to define main function. Inside main function, I am declaring two variables n1 and n2. Now I am going to declare file pointer. Name of file pointer is fp. This file pointer will be receiving address of the file from which I am going to read a number. So first I have to open that file using fopen function. So here I am passing name of file as number.txt and I have to open this file in read mode because I am going to read a number from this number.txt file. After execution of fopen function, I have to check whether this file is opened successfully or not. So for that purpose, I have implemented this if statement. It is checking fp is containing null or not. So if fp is containing null, it means file is not opened successfully. So then I can print this error message. File is not present. And then I can call exit function so that I can terminate execution of the program. And you can write any particular message that you want to display on output screen here using printf. So if fp is having null, then only this printf will be printing this message and exit will be terminating execution of the program. Otherwise this if condition will be false and the statements which will be written after this if statement will be executed. So first I am going to read a number from user. So the message enter a number will be displayed on output screen. And the entered number will be stored inside N1. After reading that number, I have to read another number from file. So for that purpose, I am using fscanf. I am passing first argument fp then %d and %n2. So the number which will be received from file will be stored inside N2 variable. And first argument is fp that is source of the file where the number will be received or retrieved. So fp is having address of number.txt. So in the system number.txt must be present and it must be having a integer number inside it. Now after reading both the input one from user and one from file, I can apply if condition. So this scanf reads input from user and fscanf is reading input from file. Now I am applying if N1 double equals to N2. So I can print the message on output screen. Numbers are equal else I can print numbers are unequal. So this way one of these messages will be displayed on output screen and after completion of calculation I can call fclose function which is closing at open file and then return 0. So this way I have implemented the complete code in front of you in which first input will be received from user and second input will be received from file. Now we have to check whether this number.txt is present in the system or not. So for that purpose you have to follow this path c, tc and bin. So you have to open c drive, tc folder and bin folder and you have to check whether number.txt is present or not. So I have already opened bin folder so you can see the path c, tc and bin. Now I am pressing N. So the file which are starting from N are available here. You can see number.txt is not available here. So without creating a file I am first executing this code so that you can see whether the error message displayed or not. So you can see the error message is displayed, error file is not present. So file is not available that's why this if condition gets executed and the message error file is not present is displayed on output screen. So to execute this program properly first we have to create this number.txt file. For that purpose I am opening notepad I am writing 10 inside this file. Now I have to save this file so I am choosing c drive, tc folder and bin. Now inside bin I am saving this file with number.txt name. So you can see in bin folder now number.txt file is available. So I am closing this file number.txt is having a number 10. So I am executing this code now it is asking for a number I am entering 10. You can see the output numbers are equal. So I have only entered 10 and another 10 is received from the file that is created by me right now. So this number.txt is also having 10 and I have also entered 10 so that's why it is showing numbers are equal. Again I am executing this code this time I am entering 20 you can see the output it is showing numbers are unequal. So this way I hope you have understood how I am reading the number from user as well as from file and I have created the file right now in front of you. So I hope you have understood how we can check the error message through read mode whether the file is present or not. How you can create new file and how you can read numbers from user from output screen and from a file and how you can compare both the values. So this is all about this problem. I hope you have understood all all the concepts which I have demonstrated you in this video. If you want to watch more programming related videos you can search my name Sanjay Gupta in YouTube. My channel will be available there you can watch various programming related videos there. Thank you for watching this video.