Discussion :: Functions - Find Output of Program (Q.No.2)
|Vishal said: (Jun 11, 2011)|
|Pointer multiplication is not allowed. Then how is it possible?|
|Moni said: (Oct 4, 2011)|
|Can anyone give the explanation?|
|Lokesh said: (Oct 31, 2011)|
|It's pointer of i(multiplied)by pointer of i
here the pointer value is the value that is present in the address of the variable .
|Rohit said: (Jan 16, 2012)|
|Can someone please help me with this
void temp(int i)
printf("%d" , i);
This program(when executed in GCC compiler) gives the output
How is it printing the elements in reverse order?
|King said: (Feb 19, 2012)|
|void temp(int i)
printf("%d" , i);
Change Your function body with this. Then Your Problem will be solved. :)
|Lakshmisravani said: (Aug 28, 2012)|
|We can use *i and *j as arguments
so that when we calling the function i and j values are entered into formal arguments *i and *j
|Jhanisi Ri said: (Sep 7, 2012)|
|What is the call by reference? please explain me.|
|Ankita said: (Sep 16, 2012)|
What is the purpose of "void fun (int*, int*);" ?
|Ruby said: (Sep 20, 2012)|
|While declaring the function its is necessary to inform the compiler about that function, so that "void fun(int*, int*);" is written before main() function. Otherwise it will produce a compilation error.|
|Rasheeda said: (Sep 27, 2012)|
|i and j values will change even there is no return statement. How ?|
|Pawankumar said: (Nov 17, 2012)|
|Here there is no return statement then how we can use the updated value of I and j ?|
|Karthik said: (Oct 2, 2013)|
|Even though return is not used in called function, how it is returning value to main function.|
|Suraj said: (Mar 2, 2014)|
|The values at the &i and &j is squared in the called function so no need to use return statement. Printf statement will display updated values at the address.|
|Thirupal said: (May 5, 2014)|
|In this question the values pass call by reference so the call function and pass the values and it stores values in the function.|
|Saumya said: (Sep 16, 2014)|
printf("\n%u %u %u", &a, b,c);
printf("\n%f %f %f %f %f %f", a,*(&a),*&a, *b,*c);
In this problem, what would be printed because of *c i.e last argument of second printf statement.
Can anybody help me out in this?
|Raj said: (May 5, 2015)|
|@Saumya, There is an unforced error in your program. In second printf statement six % of specifiers used for 5 arguments.
The output will be like this:
1229823404 1229823404 1229823404 // address of a.
13.500000 13.500000 13.500000 13.500000 13.500000 // value of a.
& - Takes the address of the variable.
* - Takes the data which is stored in the given address.
|Radha said: (Jun 27, 2015)|
|Yogeshwari said: (Nov 10, 2016)|
|As void function does not return the value.
How printf in main will print 25, 4?
|Yoboi said: (Aug 11, 2017)|
|Because call by address is used here.|
|Vilas said: (Sep 2, 2017)|
It's a recursive function, so it will call himself again n again .. in your question.
Till condition get satisfied i==10,
by i++ ;
Value of I will get increment in stack downwards. Once i become 10,
If condition will get sastisfty. So return statement comes in picture and loop will get terminated. exit.
As per the stacks, Value will print down to up, In reverse order i.e. 10 9 8 7 6 5 4 3 2....
Hope you get it.
|Pullareddy said: (Sep 13, 2017)|
|Call by reference is the with in the function we can passed the address to the variable function. That we can call the sub function that's why call the value is called call by reference.|
|Hemanth Kumar.V said: (Oct 8, 2018)|
|Actually here we are using call by the reference method, by using this method we can change the values directly present in that address.|
|Harish Mahajan said: (Oct 16, 2018)|
|Pointer multiplication is not allowed then how it is possible?|
|Dipak said: (Jun 13, 2020)|
|Pointer multiplication is not allowed in C.
But here we take multiplication of the value of pointer means *i is storing value of i so we multiply the value of i.
If it's given like i*i then this give an error because we doing multiplication of pointer which is not allowed in C.
Post your comments here:
Email : (optional)
» Your comments will be displayed only after manual approval.