7 votes 7 votes The output of the following C program will be _____ #include<stdio.h> #define type int type foo(type b) { return b*b; } #undef type #define type float int main() { float a = foo(1.1); printf("%1.2f", a); } Programming in C go-programming-1 programming programming-in-c data-types numerical-answers + – Arjun asked Oct 18, 2016 Arjun 1.6k views answer comment Share Follow See all 0 reply Please log in or register to add a comment.
Best answer 6 votes 6 votes type will take int value .Since #undef type ; #define type float ; done after the function complete that y answer is 1.00 otherwise it will be 1.21. Prashant. answered Oct 21, 2016 • selected Oct 21, 2016 by Arjun Prashant. comment Share Follow See all 12 Comments See all 12 12 Comments reply indrajeet commented Oct 28, 2016 reply Follow Share What is the meaning of #undef??? 0 votes 0 votes Prashant. commented Oct 28, 2016 reply Follow Share to cancle the meaning of #define 0 votes 0 votes sushmita commented Dec 11, 2016 reply Follow Share what is the meaning of format specifier= "%1.2f" ??? 0 votes 0 votes Sarvottam Patel commented Jan 12, 2017 reply Follow Share "%1.2f" means take two point after decimal. In exam if it is used then you must have to write 1.00 as 1 will be incorrect 5 votes 5 votes Deependra Vivek Sing commented Sep 28, 2017 reply Follow Share WHEN output would be 1.21 plz tell the case. 0 votes 0 votes vishalshrm539 commented Nov 29, 2017 reply Follow Share when there will be #define type float before the function definition. 1 votes 1 votes Anurag Parothia 1 commented Sep 30, 2018 reply Follow Share Someone please explain what if there will no #undef or no #def Does it produces any effect on the answer and what will be th answer if #define is written after #define type int ,then i think it will be 1.21 and one more thing what will be the execution in terms of lines 0 votes 0 votes Mk Utkarsh commented Oct 19, 2018 reply Follow Share Execution 1 votes 1 votes mrinmoyh commented Sep 9, 2019 reply Follow Share at this line float a = foo(1.1); foo(1.1) will replace the function code, then it should be type = float 0 votes 0 votes Mk Utkarsh commented Sep 10, 2019 reply Follow Share MRINMOY_HALDER so what are you suggesting? 0 votes 0 votes mrinmoyh commented Sep 10, 2019 reply Follow Share If inplace of foo(1.1),it's replaced with its definition then type should be float.right?? 0 votes 0 votes Mk Utkarsh commented Sep 10, 2019 reply Follow Share MRINMOY_HALDER ^ check my comment above, you'll get line by line execution 0 votes 0 votes Please log in or register to add a comment.
0 votes 0 votes float a=1.1// a is a floating type variable foo(int b)=1//take value of a as a argument so b*b=1*1=1// b is a integer type variable return 1; a=1 print as o/p. SHIVAM GARG answered Jul 25, 2018 SHIVAM GARG comment Share Follow See all 0 reply Please log in or register to add a comment.
0 votes 0 votes b will take value 1 as a argument because it is integer type so b=1*1=1 a=1 printf(" %1.2 f",a)=1.00 so o/p will be 1.00 SHIVAM GARG answered Aug 17, 2018 SHIVAM GARG comment Share Follow See all 0 reply Please log in or register to add a comment.