In the below code, how do you modify the value 'a' and print
in the function. You'll be allowed to add code only inside
the called function.

main()
{
int a=5;
function(); // no parameters should be passed
}
function()
{
/* add code here to modify the value of and print here */
}

Answer Posted / aravind

#include<stdio.h>
void function(void );
int main()
{
int a=5;
function();
}
function()
{
int a=4;
printf("%d",a); /* a here is a local variable*/
}

Is This Answer Correct ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Hai sir, I had planned to write the NIC scientific engineer exam , plz post the sample question......

1966


Explain about C function prototype?

827


Explain what is the difference between #include and #include 'file' ?

792


What are the advantages and disadvantages of a heap?

927


Is printf a keyword?

970


What is the most efficient way to count the number of bits which are set in an integer?

830


What are the different types of linkage exist in c?

793


What is c mainly used for?

824


What is pointers in c?

895


Can you return null in c?

867


Why c is known as a mother language?

843


What does double pointer mean in c?

782


What is the use of getchar() function?

856


What library is sizeof in c?

816


What is c method?

747