Can anyone tell me how can i write a program where i have to read a c program from a text file and then count the number of if-else statements, excluding the nested if-else.
Her
If you aren't stuck to Java I would suggest Python pycparser https://github.com/eliben/pycparser . If you have to use Java then check Parsing / reading C-Header files using Java