[algogeeks] Re: C Puzzle

2011-09-17 Thread Gene
This is not a C puzzle. It depends on operating system.

On Sep 17, 3:46 pm, teja bala pawanjalsa.t...@gmail.com wrote:
  you have to print the list of all the files in a directory and all
 its sub directories?

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: C Puzzle

2011-09-17 Thread pooja
i tried it for Windows.

#includeiostream

using namespace std;
int main()
{
 char ch;
 int i=system(dir /s |more);
 ch=getchar();

 }


On Sep 17, 6:46 pm, teja bala pawanjalsa.t...@gmail.com wrote:
  you have to print the list of all the files in a directory and all
 its sub directories?

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: C Puzzle

2011-09-17 Thread pooja
it's running..
http://ideone.com/XjGIo
wat is does is that through the system function u can run commands as
u do in command prompt.. nd dis is d command to show the files n all
as ur question asked.
try it on dev C++.

On Sep 17, 9:45 pm, teja bala pawanjalsa.t...@gmail.com wrote:
 @ pooja

 in borland c++ 4.5 compiler version its giving linker error,

 wat actually ur code does?







 On Sat, Sep 17, 2011 at 9:27 PM, pooja pooja27tan...@gmail.com wrote:
  i tried it for Windows.

  #includeiostream

  using namespace std;
  int main()
  {
      char ch;
      int i=system(dir /s |more);
      ch=getchar();

      }

  On Sep 17, 6:46 pm, teja bala pawanjalsa.t...@gmail.com wrote:
    you have to print the list of all the files in a directory and all
   its sub directories?

  --
  You received this message because you are subscribed to the Google Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: C puzzle

2011-09-04 Thread teja bala
but o/p is -15 -13 -11 -9

On Sun, Sep 4, 2011 at 3:38 AM, vikas vikas.rastogi2...@gmail.com wrote:

 f(19222)
  |
  |
 f(1922) -11 -2 =-13
  |
  |
 f(192) = -9 -2 = -11
  |
  |
 f(19) = f(1) - 9 = -9
  |
  |
  f(1) = 0

 output -9 -11 -13


 On Sep 3, 10:29 pm, teja bala pawanjalsa.t...@gmail.com wrote:
  Find the output of the following code - plzzz xplain the o/p
  int find(int j)
  {
  if(j1)
  {
  j=find(j/10)-(j%10);
  printf(%d,j);}
 
  else
  {
  j=0;}
  return j;
  }
 
  int main()
  {
  int i=19222;
  int k;
  k=find(i);
 
 
 
 
 
 
 
  }

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.



-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: C puzzle

2011-09-04 Thread Neha Gupta
o/p : -9-11-13-15

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: C puzzle

2011-09-04 Thread teja bala
@neha could u xplain it?

On Sun, Sep 4, 2011 at 12:05 PM, Neha Gupta nehagup...@gmail.com wrote:

 o/p : -9-11-13-15

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: C puzzle

2011-09-04 Thread NITESH KUMAR
output is :
-9-11-13-15

first j=19222 then
find(19222)=find(1922)-2
find(1922)=find(192)-2
find(192)=find(19)-2
find(19)=find(1)-9

find(1) returns 0  then
find(19)=0-9=-9
find(192)=-9-2=-11
find(1922)=-11-2=-13
find(19222)=-13-2=-15

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: C puzzle

2011-09-04 Thread Neha Gupta
@teja ...nitesh hv correctly explained it

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: C puzzle

2011-09-04 Thread annarao kataru
@nitesh   good  explanation brother

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: C puzzle

2011-09-03 Thread vikas
f(19222)
  |
  |
f(1922) -11 -2 =-13
  |
  |
f(192) = -9 -2 = -11
 |
 |
f(19) = f(1) - 9 = -9
 |
 |
 f(1) = 0

output -9 -11 -13


On Sep 3, 10:29 pm, teja bala pawanjalsa.t...@gmail.com wrote:
 Find the output of the following code - plzzz xplain the o/p
 int find(int j)
 {
 if(j1)
 {
 j=find(j/10)-(j%10);
 printf(%d,j);}

 else
 {
 j=0;}
 return j;
 }

 int main()
 {
 int i=19222;
 int k;
 k=find(i);







 }

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: C puzzle

2011-04-08 Thread cegprakash
thanks for sharing this question

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: C puzzle

2011-04-07 Thread Kamakshii Aggarwal
in fn,ptr first recieves the address of i,and then by ptr=val,it now stores
the address of val variable.

while in fn1,ptr first stores the address of i,and then by *ptr=100,value at
the address of i changes to 100.and hence it gives 100 as the answer.

On Thu, Apr 7, 2011 at 9:29 AM, rohit agarwal agarwal.rohi...@gmail.comwrote:

 I fn we are simply changing the address in ptr means ptr will now points to
 another variable i.e val

 In fn1 we are changing the value of a variable to which ptr is pointing i.e
 i so i will be changed.

  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
Regards,
Kamakshi
kamakshi...@gmail.com

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: C puzzle

2011-04-06 Thread Don
In fn, ptr is a local variable passed by value. Changing ptr in the
function does not change anything in main.
Don

On Mar 31, 10:35 pm, navin navin.myhr...@gmail.com wrote:
 see this c code.

 #includestdio.h

 void fn (int *ptr)
 {
        const int val=100;
        ptr=val;}

 void fn1(int *ptr)
 {
        *ptr = 100;

 }

 main()
 {
        int i=10;
        printf(%d , i);
        fn(i);
        printf(%d , i);
        fn1(i);
        printf(%d , i);

 }

 What is the difference between fn and fn1?
 I expected the output to be 10 100 100
 but it came as 10 10 100.
 can anyone explain what happens in fn.
 why 100 in fn is not stored in ptr.

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: C puzzle

2011-04-06 Thread rohit agarwal
I fn we are simply changing the address in ptr means ptr will now points to
another variable i.e val

In fn1 we are changing the value of a variable to which ptr is pointing i.e
i so i will be changed.

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.