the outpu is hello coz the pointer is pointing to a
location where the string "bye" is written in the next
program yu are using the same pointer to point to some
other string so it gets overwritten
SOORY FOR POSTIN THE WRONG ANSWER THE ANSER WUD BE BYE COZ
THE *P DIES IN THE FUNCTION ITSELF AS WE ARE NOT RETURNING
THE STRING BACK IN THE MAIN PROGRAM
the output wll be hello , since the argument is overwritten
with new memory in the function.
so in main, when it comes to printf, p points to the
allocatd memory, which contains hello
The out put is "BYE".
Because the pointer p dies when function exit with out
return,in main pointer p points to only "BYE",so prinf
prints which p points in main.
The output would be "HELLO"..
though we are not returning the string, we are making
direct changes at the memory location..
so "bye" will be overwritten with "HELLO"
because we are using pointers, the dying pointer scenario
is not applicabe here..
Its a pointer, not a variable..
This function will work similar to -> swapping two numbers
using pointers..
juss check that prog if you fnd somewhere.. :-)
you will get the logic... :-)
Cheers...
--By the way a gud ques.. :-)
5. What kind of sorting is this:
SORT (k,n)
1.[Loop on I Index]
repeat thru step2 for i=1,2,........n-1
2.[For each pass,get small value]
min=i;
repeat for j=i+1 to N do
{
if K[j]<k[min]
min=j;
}
temp=K[i];K[i]=K[min];K[min]=temp;
3.[Sorted Values will be returned]
A)Bubble Sort
B)Quick Sort
C)Selection Sort
D)Merge Sort
Which of the following about automatic variables within a
function is correct ?
a.its type must be declared before using the variable
b.they are local
c.they are not initialised to zero
d.they are global.