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

A banker has a seif with a cipher. Not to forget the cipher, he wants to write it coded as following: each digit to be replaced with the difference of 9 with the current digit. The banker chose a cipher. Decipher it knowing the cipher starts with a digit different than 9. I need to write a program that takes the cipher from the keyboard and prints the new cipher. I thought of the following: Take the input from the keyboard and put it into a string or an array. Go through the object with a for and for each digit other than the first, substract it from 9 and add it to another variable. Print the new variable. Theoretically I thought of it but I don't know much C. Could you give me any kind of hint, whether I am on the right track or not?

1770


What are type modifiers in c?

832


Is it better to bitshift a value than to multiply by 2?

881


What are reserved words with a programming language?

859


What do header files do?

841


How can a process change an environment variable in its caller?

945


Are there any problems with performing mathematical operations on different variable types?

829


What is the -> in c?

812


Can you please explain the difference between exit() and _exit() function?

846


which is conditional construct a) if statement b) switch statement c) while/for d) goto

1015


What is variable and explain rules to declare variable in c?

819


How do you search data in a data file using random access method?

1112


What is an example of structure?

813


What is the modulus operator?

961


How can I manipulate strings of multibyte characters?

836