Implement an algorithm that reads a mathematical expression from the standard input and writes to Standard output if the expression is correctly bracketed.
I made the code but I do not know if it's okay how I used the file.
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
int main()
{
FILE *citire, *scriere;
char expr[100];
int fe=0,i;
citire = fopen("in.txt", "rb");
scriere = fopen("out.txt", "wb");
fscanf(citire, "%s", &expr);
//input
i = 0;
while (expr[i] != '\0')
{
if (expr[i] == '(')
{
fe++;
}
else if (expr[i] == ')')
{
fe--;
if (fe < 0)
break;
}
i++;
}
//output
if (fe == 0)
{
fprintf(scriere, "DA\n");
}
else
{
fprintf(scriere, "NU\n");
}
fclose(citire);
fclose(scriere);
return 0;
}