Click here to Skip to main content
15,886,857 members

Comments by Parth Vijay (Top 8 by date)

Parth Vijay 27-Nov-22 0:15am View    
Thanks Sir, I made changes in my own code now its working fine!
Changes Made(in my code):
-------------
n = n*n;
n n n%MOD; (change)
x = x/2;
-------------
res = res*n;
res = res % MOD;
x--;
------------
after all changes no need for this line(before the return res;):
res = res%MOD;
------------
Will read more about this<>
Parth Vijay 3-Nov-22 20:19pm View    
ok, i got the mistake and got the correct answer..
Parth Vijay 8-Oct-22 6:03am View    
So, i came to point where i find that fgets is much better than scanf..
Bcoz fgets takes '\n' in its string when we press enter which we can remove by making a function something like u have made and on the other side scanf stops taking an input when it encounters an enter key and the pressed enter key is left in the buffer which will create a problem for the upcoming input function (scanf,fgets,gets etc). So, to remove this problem what i did i just found the definition of the scanf fucntion in the (stdio.h) file by the help of debugger(step in feature) and added this fflush(stdin) before returning anything...

And i run the program it is working and i dont have to care now where to add this fflush(stdin) statement..
i want to ask if this is correct approach. means like changing the original code will affect me in future?
Parth Vijay 3-Oct-22 6:56am View    
Yes sir, The first need was to know the mistake in my own code then moving on to some other ideas..
Parth Vijay 3-Oct-22 6:50am View    
thank you, for the additional functions now get to know them.. But, i'm using them because i have encountered this situation for the very first time.. So, my approach is learn how their codes are written.. If i don't write them i will never understand how they works (what are logics used to write that fucntion).. In near future i will use these shortcuts to save time;..thnaks again