3 votes 3 votes Point out the error : #include <stdio.h> void f(int*); int main() { int i=35,*z; z=f(&i); printf("%d",z); return 0; } void f(int*m) { return(m+2); } error in function call error in return statement error in argument of f() error in pointer initialization Programming in C tbb-programming-2 + – Bikram asked May 14, 2017 • edited Aug 19, 2019 by Counsellor Bikram 566 views answer comment Share Follow See 1 comment See all 1 1 comment reply JashanArora commented Dec 27, 2019 reply Follow Share Void functions can't return values. You can, however, write return statements in them at the end to enhance user readability. https://stackoverflow.com/questions/22719242/returning-a-value-from-a-void-function 0 votes 0 votes Please log in or register to add a comment.
Best answer 7 votes 7 votes A void function cannot return a value though it can have a return statement. So, the answer is B. Samridhi Tyagi answered May 20, 2017 • selected May 21, 2017 by Arjun Samridhi Tyagi comment Share Follow See all 8 Comments See all 8 8 Comments reply Bikram commented May 21, 2017 reply Follow Share yes you are correct, when we use void as return type it makes Return keyword as of no use .. hence option B is correct, it provides error in return statement . Reference: http://stackoverflow.com/questions/17801793/function-cannot-return-a-value 0 votes 0 votes joshi_nitish commented May 21, 2017 reply Follow Share void function can also return value..it will cause no problem but if void function is used as a Rvalue for any statement than it will cause error.. 1 votes 1 votes Samridhi Tyagi commented May 21, 2017 reply Follow Share even if u want to write a return statmnt for a void function(which is incorrect but lets suppose it compiles successfully ) then also return should be written like return; and not return(m+2); and also isnt it wrong that u have declred a function as void and then writing a return stmt to it 2 votes 2 votes joshi_nitish commented May 21, 2017 reply Follow Share #include <stdio.h> void main(int n) { printf("hello"); return n; } 0 votes 0 votes Bikram commented May 25, 2017 reply Follow Share @Tyagi #include <stdio.h> void main(int n) { printf("hello"); return n; } gives output as " hello " so it return a value while return type is void . 0 votes 0 votes val_pro20 commented Jan 6, 2019 reply Follow Share @joshi_nitish @Bikram even if u want to write a return statemnt for a void function(which is incorrect but lets suppose it compiles successfully ) then also return should be written like return; and not return(m+2);is it valid 0 votes 0 votes Sambhrant Maurya commented Jul 15, 2019 reply Follow Share z=f(&i); Is this correct? What does it mean? 0 votes 0 votes Bikram commented Aug 19, 2019 reply Follow Share https://gateoverflow.in/129778/test-by-bikram-2017-programming-test-2-18?show=130298#c130298 https://gateoverflow.in/129778/test-by-bikram-2017-programming-test-2-18?show=130312#c130312 0 votes 0 votes Please log in or register to add a comment.