2 votes 2 votes #include<stdio.h> #include<math.h> int main(){ int M_PI=25; printf("%d",M_PI); return 0; } Run Time Error Compile Time Error 25 Gargabe value Programming in C programming-in-c + – himanich asked Jul 16, 2016 • edited Oct 6, 2016 by go_editor himanich 589 views answer comment Share Follow See 1 comment See all 1 1 comment reply Habibkhan commented Oct 6, 2016 reply Follow Share If math.h file is included it will give error as M_PI is constant defined in math.h whereas if we declare M_PI without math.h header file , this works fine. U can refer : http://www.c4learn.com/c-programming/c-variable-nameing-rules/ Consider the "tip 9" of this link. 1 votes 1 votes Please log in or register to add a comment.
Best answer 1 votes 1 votes Ans 2 It is a typical tricky question from C. Constant M_PI is already defined in math.h to store value of pi. In main () we are declaring a constant with same name M_PI So compiler throws an error If math.h is not included, the code will print 25 sh!va answered Jul 17, 2016 • selected Jul 17, 2016 by ManojK sh!va comment Share Follow See all 5 Comments See all 5 5 Comments reply himanich commented Jul 17, 2016 reply Follow Share @shiva can you explain ? why 0 votes 0 votes Anjali_aspirant commented Jul 17, 2016 reply Follow Share Why compiler time error.. Can u plse explain? 0 votes 0 votes sh!va commented Jul 17, 2016 reply Follow Share Explanation is added. I Hope it is useful :) 0 votes 0 votes Anjali_aspirant commented Jul 17, 2016 reply Follow Share Thanks:) 0 votes 0 votes ManojK commented Jul 17, 2016 reply Follow Share Reason:http://www.gnu.org/software/libc/manual/html_node/Mathematical-Constants.html 1 votes 1 votes Please log in or register to add a comment.