[algogeeks] Re: C Macro

2012-10-30 Thread Ankit Tripathi
Besides i prefer to write the following #define which is generic and works in all case, i.e., it doesn't matter whether you pass pointers, float, int, etc; *#define swap( a, b )size_t t; t = a; a = b; b = t;* 1 more thing now you don't have to pass any other information i.e., whether your

Re: [algogeeks] Re: c code help!!!!

2012-10-25 Thread rahul sharma
Please dont reply to thi post..wrng questionsry for that On Fri, Oct 26, 2012 at 2:31 AM, rahul sharma wrote: > address of each byte is printed...each byte is 32 bit long...so 32/4=8 hex > for each row...but how these are separated with %.2x tin group of > 2's%.2x means min. 2 width ..if

Re: [algogeeks] Re: c code help!!!!

2012-10-25 Thread rahul sharma
address of each byte is printed...each byte is 32 bit long...so 32/4=8 hex for each row...but how these are separated with %.2x tin group of 2's%.2x means min. 2 width ..if <2..then leading zeros... so it should be ("%.2x",start[i]); start[i] in 2 but it is more so ignored...print start[i]s

Re: [algogeeks] Re: c code help!!!!

2012-10-25 Thread rahul sharma
As per o/p below: 00 00 80 3f 01 00 00 00 44 ff 28 00 01 00 00 00 first byte address is first row. second byte address is second row. third byte address third row and so on but how first row containg 3 values...as 1byte=2hexdigits..si only two digits must be there. and u said 44 ff 28 00 is ad

Re: [algogeeks] Re: c code help!!!!

2012-10-21 Thread Saurabh Kumar
Sorry, I don't understand your question. *%.2x *is only a precision specifier still. (%.2x was used for neat formatting only, because you are printing the values only 1 Byte long and a Byte can occupy at max 2digits in hex) hex representated by 4 bits. Yes hex is represented by 4 bits i.e. 1 B

Re: [algogeeks] Re: c code help!!!!

2012-10-21 Thread Saurabh Kumar
Sorry, about that. Read it as: Yes a hex digit is represented by 4 bits but 1 Byte is being read using a char pointer* and you're printing the values in those Bytes. On 21 October 2012 01:03, Saurabh Kumar wrote: > Sorry, I don't understand your question. *%.2x *is only a precision > specifier s

[algogeeks] Re: c code help!!!!

2012-10-20 Thread rahul sharma
Actually i have taken form http://www.geeksforgeeks.org/archives/730 Please explain me o/p...as hex representated by 4 bitsthen how cum is following o/p 00 00 80 3f 01 00 00 00 44 ff 28 00 01 00 00 00 total we have to represent 32 bits and 8 bits in eachplz xplain On Sun, Oct 21, 20

Re: [algogeeks] Re: C prog o/p

2012-10-16 Thread Ashok Varma
i - j is giving -3 as output. why is this so ? On Tue, Oct 16, 2012 at 11:18 PM, iwill wrote: > how to explain the output if instead of j-i we try to print i-j ? > > > On Saturday, October 13, 2012 3:36:49 PM UTC+5:30, bharat wrote: >> >> #include >> main() >> { >> int *i,*j; >> i=(int*)60; >>

[algogeeks] Re: C prog o/p

2012-10-16 Thread iwill
how to explain the output if instead of j-i we try to print i-j ? On Saturday, October 13, 2012 3:36:49 PM UTC+5:30, bharat wrote: > > #include > main() > { > int *i,*j; > i=(int*)60; > j=(int*)71; > printf("%d",j-i); > } > -- You received this message because you are subscribed to the Googl

[algogeeks] Re: c o/p

2012-10-07 Thread rahul sharma
Sorry wrng question copiedits a silly question to be asked..sorry guys On Sun, Oct 7, 2012 at 6:06 PM, rahul sharma wrote: > #include > int main() > { > int i; > char ch; > > scanf("%c",&ch); > > printf("%d",ch); > // getchar(); > getchar(); > } > > when i enter one dig

[algogeeks] Re: C output

2012-07-03 Thread shiv narayan
6/5=1, in integer division, how come you can think it as 2? On Tuesday, 3 July 2012 13:22:07 UTC+5:30, rahul sharma wrote: > > #include > #include > int main() > { > int i; > i=5; > i=++i/i++; > printf("%d",i); > getch(); > } > > Why o/p is 1 and not 2?? what happened for p

[algogeeks] Re: c++_Output

2012-01-21 Thread Dave
@Kailash: The code violates the sequence point rule, which says that you may not change the value of a variable more than once between sequence points. The result is compiler dependent. Dave On Jan 21, 5:42 am, Kailash Bagaria wrote: > Please explain the output of the following program > > #

Re: [algogeeks] Re: c output

2011-09-21 Thread sukran dhawan
its right to left On Wed, Sep 21, 2011 at 7:41 PM, kartik sachan wrote: > thanks sukran... > i have one more question evaluation of printf is also undefined in C?? > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to t

Re: [algogeeks] Re: c output

2011-09-21 Thread kartik sachan
thanks sukran... i have one more question evaluation of printf is also undefined in C?? -- 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, s

Re: [algogeeks] Re: c output

2011-09-21 Thread sukran dhawan
hmmm it is compiler dependent... try out with different compilers... but even though dey give same results,standard c left this eature as undefined for efficiency purposes On Wed, Sep 21, 2011 at 7:16 PM, kartik sachan wrote: > @sukran if it is undefined in ansi c so it can return any value??? >

Re: [algogeeks] Re: c output

2011-09-21 Thread kartik sachan
@sukran if it is undefined in ansi c so it can return any value??? at complilaton.but all time it is giving me same value -- 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

Re: [algogeeks] Re: c output

2011-09-21 Thread sukran dhawan
IT is not the case ... I already said acc to ANSI c result is undefined !! not 0 by dault On Wed, Sep 21, 2011 at 6:50 PM, kartik sachan wrote: > ans in both cases is zero > i think if return is written and nthg specified value is given it will > return by default zero > > -- > You re

Re: [algogeeks] Re: c output

2011-09-21 Thread kartik sachan
ans in both cases is zero i think if return is written and nthg specified value is given it will return by default zero -- 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 unsubs

[algogeeks] Re: c output,printf("%llx")

2011-09-19 Thread Dave
@Wujin: Okay. b is but an integer, yet it is being printed as a long long. Since there are no implicit type conversions in procedure calls such as the printf statement, b is taken as a long long, not of an int. So b and the next 32-bits are printed. The format that these are printed in is a figment

[algogeeks] Re: c output,printf("%llx")

2011-09-19 Thread Dave
@Wujin: Okay. But b is an integer and it is being printed as a long long. Since there are no implicit type conversions in procedure calls such as the printf statement, b is taken as a long long, not of an int. So b and the next 32-bits are printed. Dave On Sep 19, 8:18 pm, wujin chen wrote: > @D

Re: [algogeeks] Re: c output,printf("%llx")

2011-09-19 Thread wujin chen
@Dave printf("a=%x, b=%llx",a,b,c); i think c will be ignored~~ , and the output is a=9,b=10 2011/9/19 Dave > @Wujin: What do you expect the output to be? How does it differ from > what you actually get? > > Dave > > On Sep 18, 8:47 am, wujin chen wrote: > > usigned long long x = 0x12345678;

[algogeeks] Re: C-dot Interview Questions

2011-09-19 Thread Harshit Sethi
thanks siddharam,but i am form computers .I have given my interview.I heard that C-dot asks questions from networking.But since networking was not in our syllaybus i was too worried as i had only 2-3 hrs to read about that .I took an idea about networking,but wasn't confident that i will be able

Re: [algogeeks] Re: c output

2011-09-19 Thread Bhavesh agrawal
abhishek can you plz explain -- 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 opti

Re: [algogeeks] Re: c output

2011-09-19 Thread sukran dhawan
According to K and R c book , when the return value is specified and yet we fail to return a value, it is undefined. It is compiler dependent. So i feel there is no meaning in thinking abt it On Mon, Sep 19, 2011 at 4:38 PM, abhishek wrote: > @ sukran > if it is giving same ans then there has

[algogeeks] Re: c output

2011-09-19 Thread abhishek
@ sukran if it is giving same ans then there has to be some reason, On Sep 19, 12:45 pm, sukran dhawan wrote: > common guys its undefined acc to standard c > > On Mon, Sep 19, 2011 at 12:36 PM, Siddhartha Banerjee < > > > > > > > > thefourrup...@gmail.com> wrote: > > on running,every ti

[algogeeks] Re: c output

2011-09-19 Thread abhishek
output is 18 9 0 0 0 8 the same was expected. printf uses stack when it has multiple arguments to print On Sep 18, 1:19 pm, Bhavesh agrawal wrote: > another que.. > > #include > main() > { >     int a; >     int i=10; >     printf("%d %d %d\n",i+++i,i,i---i); >     printf("%d\n",i---i); >     a

[algogeeks] Re: c output,printf("%llx")

2011-09-18 Thread Dave
@Wujin: What do you expect the output to be? How does it differ from what you actually get? Dave On Sep 18, 8:47 am, wujin chen wrote: > usigned long long x = 0x12345678; > int a = 0x09; > int b = 0x10; > printf("a=%x, b=%llx",a,b,c); > > the result is: a=9,b=123456780010 > > i wonder why~~

[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 wrote: > @ pooja > > in borland c++ 4.5 compiler

Re: [algogeeks] Re: C Puzzle

2011-09-17 Thread teja bala
@ 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 wrote: > i tried it for Windows. > > #include > > using namespace std; > int main() > { > char ch; > int i=system("dir /s |more"); > ch=getchar();

[algogeeks] Re: C Puzzle

2011-09-17 Thread pooja
i tried it for Windows. #include using namespace std; int main() { char ch; int i=system("dir /s |more"); ch=getchar(); } On Sep 17, 6:46 pm, teja bala wrote: >  you have to print the list of all the files in a directory and all > its sub directories? -- You received thi

[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 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 pos

Re: [algogeeks] Re: c output .. help plz

2011-09-07 Thread Sanjay Rajpal
+1 dave. Sanju :) On Tue, Sep 6, 2011 at 3:40 PM, Dave wrote: > @Srivastav: Yeah. You need more parens: > > printf("%d",(int)(3.14*6.25*6.25)); > > Without the extra parens, the 3.14 is cast to an int, but then > implicitly recast to a double for the multiplications. With the > parens, the p

[algogeeks] Re: c output .. help plz

2011-09-06 Thread Dave
@Srivastav: Yeah. You need more parens: printf("%d",(int)(3.14*6.25*6.25)); Without the extra parens, the 3.14 is cast to an int, but then implicitly recast to a double for the multiplications. With the parens, the product is formed in type double, and then the result is cast into integer. Sorry

Re: [algogeeks] Re: c output .. help plz

2011-09-06 Thread UTKARSH SRIVASTAV
printf behaves abnormally when it sees arguments not matching with its datatype @dave printf("%d",(int)3.14*6.25*6.25); is also giving 0. -- *UTKARSH SRIVASTAV CSE-3 B-Tech 3rd Year @MNNIT ALLAHABAD* -- You received this message because you are subscribed to the Google Groups "Algo

[algogeeks] Re: c output .. help plz

2011-09-06 Thread Dave
@Sisavknesh: The product of those integers is 122.65625, which is 122 and 21/32. It turns out that the low order 42 bits of the mantissa are zero. Since numbers on PCs are stored little-endian, and because you asked for an integer format conversion, the first 32 of those 42 bits are treated as an i

[algogeeks] Re: C output????

2011-09-06 Thread siva viknesh
thanks a lot guys :) On Sep 6, 11:48 am, Rajeshwar Patra wrote: > pointer points to read only memory location > and this address is then compared whch evaluates to true > hence the output... -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. T

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 mo

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.

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

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 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 t

Re: [algogeeks] Re: C puzzle

2011-09-03 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

Re: [algogeeks] Re: C puzzle

2011-09-03 Thread teja bala
but o/p is -15 -13 -11 -9 On Sun, Sep 4, 2011 at 3:38 AM, vikas 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 wrote: > > Find the output of the

[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 wrote: > Find the output of the following code - plzzz xplain the o/p > int find(int j) > { > if(j>1) > { > j=find(j/10)-(j%10); > printf

[algogeeks] Re: c problem

2011-09-03 Thread Ankuj Gupta
because your are trying to edit an unmodifiable object which C- compiler will not allow On Sep 3, 6:18 pm, priya ramesh wrote: > ok but y does the compiler say lvalue required if you perform a++?? -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" gr

[algogeeks] Re: C output

2011-08-31 Thread abhishek
it will be 4 3 On Aug 31, 9:01 pm, aditi garg wrote: > sorry my mistake... > it wud be 4 3 > > second output is quite obvious as it will count till it get string termination and in first one it is a pointer to character so it will be of size 4. > > > > > > > > On Wed, Aug 31, 2011 at 9:30 PM,

Re: [algogeeks] Re: c program

2011-08-28 Thread aditya kumar
yes i agree since in the question they dint mention so we can solve it the other way also . On Sun, Aug 28, 2011 at 7:31 PM, saurabh singh wrote: > Well if you go on using system calls functions etc the job can easily be > done in many ways but the real idea behind the quine problem is the good

Re: [algogeeks] Re: c program

2011-08-28 Thread saurabh singh
Well if you go on using system calls functions etc the job can easily be done in many ways but the real idea behind the quine problem is the good old spirit of a challenge (not merely for an interview) So the best way remains the store everything way... On Sun, Aug 28, 2011 at 3:11 PM, aditya kuma

Re: [algogeeks] Re: c program

2011-08-28 Thread aditya kumar
one more method : use system funtion . eg system("cat filename") //system funtion executes the command On Sun, Aug 28, 2011 at 1:51 PM, UTKARSH SRIVASTAV wrote: > good logic > > > On Sun, Aug 28, 2011 at 12:14 AM, Piyush Grover > wrote: > >> yeah you can do that by opening the file and printing

Re: [algogeeks] Re: c program

2011-08-28 Thread UTKARSH SRIVASTAV
good logic On Sun, Aug 28, 2011 at 12:14 AM, Piyush Grover wrote: > yeah you can do that by opening the file and printing it but as far as I > know, interviewer adds the constraint of not using the file method. > > > On Sun, Aug 28, 2011 at 12:35 PM, rahul sharma wrote: > >> this logic is ok...bu

Re: [algogeeks] Re: c program

2011-08-28 Thread Piyush Grover
yeah you can do that by opening the file and printing it but as far as I know, interviewer adds the constraint of not using the file method. On Sun, Aug 28, 2011 at 12:35 PM, rahul sharma wrote: > this logic is ok...but we have pre defined everything in char f...if i > add one or two more stateme

[algogeeks] Re: c program

2011-08-28 Thread rahul sharma
this logic is ok...but we have pre defined everything in char f...if i add one or two more statements then it will require corresponding change in char *f...can i open the same file with f open n prin t it out? On Aug 28, 11:31 am, Piyush Grover wrote: > char*f="char*f=%c%s%c;main(){printf(f,

[algogeeks] Re: c program

2011-08-28 Thread rahul sharma
got it...thnkx On Aug 28, 11:31 am, Piyush Grover wrote: > char*f="char*f=%c%s%c;main(){printf(f,34,f,34,10);}%c"; > > f is a global pointer to the char array which contains the string > "char*f=%c%s%c;main(){printf(f,34,f,34,10);}%c" > > Now in main function you are printing this string with arg

Re: [algogeeks] Re: c program

2011-08-27 Thread Piyush Grover
char*f="char*f=%c%s%c;main(){printf(f,34,f,34,10);}%c"; f is a global pointer to the char array which contains the string "char*f=%c%s%c;main(){printf(f,34,f,34,10);}%c" Now in main function you are printing this string with arguments 34,f,34,10. ASCII value of " is 34. ->So in f, the first %c is

[algogeeks] Re: c program

2011-08-27 Thread rahul sharma
i m not able to understand hw it wokrs..elaborate it On Aug 28, 11:16 am, rahul sharma wrote: > plz expalin char*f="            " > > On Aug 28, 11:12 am, Piyush Grover wrote: > > > > > > > > > it's a quine problem. > > > char*f="char*f=%c%s%c; > > main(){ > > printf(f,34,f,34,10);}%c"; > >

[algogeeks] Re: c program

2011-08-27 Thread rahul sharma
plz expalin char*f="" On Aug 28, 11:12 am, Piyush Grover wrote: > it's a quine problem. > > char*f="char*f=%c%s%c; > main(){ > printf(f,34,f,34,10);}%c"; > > main() > { > printf(f,34,f,34,10); > > } > > I have used whitespaces to make it understand. > > On Sun, Aug 28, 2011 at 11:39

[algogeeks] Re: C Trick

2011-08-26 Thread Dave
@Rajesh: abs() can be done without conditional operations. There probably are many ways. The first two that come to mind are: abs(x) = (x >> 31) & x | ~(x >> 31) & ~x abs(x) = (x >> 31) ^ x + (x >> 31) & 1 Dave On Aug 26, 2:56 am, rajesh singarapu wrote: > abs function itself has a condition??

Re: [algogeeks] Re: C Trick

2011-08-26 Thread rajesh singarapu
abs function itself has a condition?? I think it is not that good solution. On Wed, Aug 24, 2011 at 6:33 PM, priyanka raju wrote: > > > int a,b,max,min; > max=(a+b+abs(a-b))/2; > min=(a+b-abs(a-b))/2; > > -- > cheers > priyanka > > -- > You received this message because you are subscribed to

Re: [algogeeks] Re: C dot

2011-08-24 Thread Dipankar Patro
C-Dot procedure (For Computers): - First shortlist on the basis of cgpa/ %age for interviews. - Only one round of interview, based on your resume. Discussion of projects and questions related to mainly OS, Networking and Programming. There is nothing as selection of "Toppers" only. If you are goo

Re: [algogeeks] Re: C-hexadecimal doubt

2011-08-24 Thread saurabh singh
On Thu, Aug 25, 2011 at 2:04 AM, Ninad Page wrote: > If you stick to one convention its not that difficult to code without > bothering about endian's.In your case if you want to have a variable data > size for int(As far as I can guess),develop ur own integer interface using > raw bytes like you

[algogeeks] Re: C code scanf problem

2011-08-24 Thread KK
Using getchar() after the first scanf ll be much better...!! -- 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...

[algogeeks] Re: C-hexadecimal doubt

2011-08-24 Thread Ninad Page
On Aug 24, 11:41 pm, Arun Vishwanathan wrote: > @don: so if a 16bit value is put into a 32 bit field and i need to read the > value, do i need to read last 16 bits only somehow ? > > > > > > As long as you are saving those 16 bits in a variable (an integer, a bit-field or otherwise), you don't

[algogeeks] Re: C code scanf problem

2011-08-24 Thread Ninad Page
On Aug 24, 6:00 pm, Sanjay Rajpal wrote: > after first scanf, place a call to fflush(stdin). > > you will get the result. > > Sanju > :) > > > Flushing the input stream is undefined. > > > > > On Wed, Aug 24, 2011 at 5:58 AM, Mehnaaz wrote: > > #include > > #define max 30 > > int no_p; > > i

Re: [algogeeks] Re: C-hexadecimal doubt

2011-08-24 Thread Arun Vishwanathan
@don: so if a 16bit value is put into a 32 bit field and i need to read the value, do i need to read last 16 bits only somehow ? On Wed, Aug 24, 2011 at 8:22 PM, Don wrote: > It is most common to use 4 bytes to store an integer value, even if > the full range will not be used. There is no proble

[algogeeks] Re: C-hexadecimal doubt

2011-08-24 Thread Don
It is most common to use 4 bytes to store an integer value, even if the full range will not be used. There is no problem putting a 16-bit value into a 32-bit field. The only case where this is not true is when memory is extremely limited and you need to pack as much into every word as possible. Do

Re: [algogeeks] Re: C doubt

2011-08-24 Thread Arun Vishwanathan
thanks guys! On Wed, Aug 24, 2011 at 6:37 PM, Don wrote: > Yes, the memory provided by malloc will not be in the structure. Only > the pointer to that memory will be in the structure. The size of a > struct is defined at compile time, so it can't be dynamically sized at > run time. > > struct ju

[algogeeks] Re: C doubt

2011-08-24 Thread Don
Yes, the memory provided by malloc will not be in the structure. Only the pointer to that memory will be in the structure. The size of a struct is defined at compile time, so it can't be dynamically sized at run time. struct junk { int size; int *data; }; Somewhere in the code: struct junk m

[algogeeks] Re: C code scanf problem

2011-08-24 Thread Mehnaaz
that was actually a mistake , i should have taken the value before i declared it BUT as for arrays goes, we know we can access the a[10] even though we may just declare a[5] ! may be its the same reason i was able to read in "for" loop besides here having the size of column matters more than th

Re: [algogeeks] Re: C doubt

2011-08-24 Thread sagar pareek
See if we use dynamic memory allocation then still the size of pointer will be 4 bytes only Mean that int* pointer still have the size equals to pointer ... malloc only returns new alloted memory which is now only *pointed *by that pointer check this out :- http://www.ideone.com/20ayq On Wed

[algogeeks] Re: C code scanf problem

2011-08-24 Thread Anurag Gupta
@ Mehnaaz :the variable no_p will be equal to 0,since it is an external one so the declaration char p[no_p][max] is equivalent to p[0][max]; and size of p is zero. then how you can insert anything into it as you are doing in for loop? no_p may receive some non zero value afterwards but array p is

[algogeeks] Re: C doubt

2011-08-24 Thread Don
If you are working in C++, stl has a vector container class which will do this. Otherwise, declare an integer pointer in the struct and use malloc to allocate memory for it. Then you can use it like an array. Don On Aug 23, 11:51 pm, Arun Vishwanathan wrote: > say that you have a structure with s

[algogeeks] Re: C code scanf problem

2011-08-24 Thread Don
The problem is that scanf("%c" will take whatever character is next, even if it is not the one you think you typed. When you typed your first entry, the number "3" and then pressed "Return", the "\n" character is left in the buffer, so your scanf gets that character instead of the one you want. The

[algogeeks] Re: C code scanf problem

2011-08-24 Thread Mehnaaz
@ vikas ..the space actually worked !!..is there any explanation ??..thanks a ton! -- 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

Re: [algogeeks] Re: C code scanf problem

2011-08-24 Thread lakshay girdhar
i hav executed it in dev.. it waits for second scanf On Wed, Aug 24, 2011 at 7:05 PM, Mehnaaz wrote: > @lakshay and sanju.after placing fflush(stdin), i am continuing to get > the same output...is there anything else i can do..? and will you also > please execute and see > > -- > You received th

[algogeeks] Re: C code scanf problem

2011-08-24 Thread Mehnaaz
@lakshay and sanju.after placing fflush(stdin), i am continuing to get the same output...is there anything else i can do..? and will you also please execute and see -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send e

Re: [algogeeks] Re: C Trick

2011-08-24 Thread Sanjay Rajpal
nice solution priyanka :) Sanju :) On Wed, Aug 24, 2011 at 6:03 AM, priyanka raju wrote: > > > int a,b,max,min; > max=(a+b+abs(a-b))/2; > min=(a+b-abs(a-b))/2; > > > -- > cheers > priyanka > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks"

Re: [algogeeks] Re: C Trick

2011-08-24 Thread priyanka raju
int a,b,max,min; max=(a+b+abs(a-b))/2; min=(a+b-abs(a-b))/2; -- cheers priyanka -- 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] Re: C Trick

2011-08-23 Thread Dave
@Abhishek: int c = (a - b) >> 31; max = c & b | ~c & a; Explanation: c = 0 if a >= b, else c = all one bits. Then c & b = 0 if c = 0, but c & b = b if c = all ones, i.e. if the max is b, and ~c & a = a if c = 0, i.e., if the max is a, but ~c & a = 0 if c = all ones. Dave On Aug 23, 8:07 am, Abh

Re: [algogeeks] Re: C dot

2011-08-23 Thread Yogesh Bhati
can any1 tell me wat type of question are asked in TCS nd INFOSYS interview. -- 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 algog

Re: [algogeeks] Re: C dot

2011-08-23 Thread Abhishek Yadav
Moreover they also asked what is .NET as if they heard it for the first timecome on...can you believe it...!!! On Tue, Aug 23, 2011 at 4:18 PM, Dheeraj Sharma wrote: > yeah..the interview was total nakli :D .. they always..take the toppers.. > :) i mean..among the top ten who are sitting.. >

Re: [algogeeks] Re: C dot

2011-08-23 Thread Dheeraj Sharma
yeah..the interview was total nakli :D .. they always..take the toppers.. :) i mean..among the top ten who are sitting.. @Sachin:- they also asked , what is Drishti ? :D On Tue, Aug 23, 2011 at 1:54 PM, Sanjay Rajpal wrote: > 7.7 LPA @ NIT Kurukshetra. > > > Sanju > :) > > > > On Mon, Aug 22, 20

Re: [algogeeks] Re: C dot

2011-08-23 Thread Sanjay Rajpal
7.7 LPA @ NIT Kurukshetra. Sanju :) On Mon, Aug 22, 2011 at 10:47 PM, siddharam suresh wrote: > how much they are offering ? > Thank you, > Siddharam > > > > On Tue, Aug 23, 2011 at 11:12 AM, ranjith kumar > wrote: > >> >> >> They shortlist candidates based on cgpa and select the highest cgp

Re: [algogeeks] Re: C-question

2011-08-23 Thread Sanjay Rajpal
to clear ur these concepts , i think u should refer to Programming in C , Schaum series, Byron S Gottfried, and then Ritchie book. They are clearly given there. Sanju :) On Mon, Aug 22, 2011 at 11:25 PM, Vijay Khandar wrote: > Thanks ...got it.. > > > On Tue, Aug 23, 2011 at 11:30 AM,

Re: [algogeeks] Re: C-question

2011-08-22 Thread Vijay Khandar
Thanks ...got it.. On Tue, Aug 23, 2011 at 11:30 AM, binayakranjan das wrote: > In this case = has right to left associativity and as such < has no > associativity.but,the parsing occurs from left to right.so first (x is checked which evaluates to 0 then (0 that is what is assigned to i

[algogeeks] Re: C-question

2011-08-22 Thread binayakranjan das
In this case = has right to left associativity and as such < has no associativity.but,the parsing occurs from left to right.so first (x wrote: > main() > { > int x=10,y=10,z=5; > int i=x pf("\n%d",i); > > } > > o/p is 1 .pls any1 explain me hw is it printing? -- You received this message because

Re: [algogeeks] Re: C dot

2011-08-22 Thread siddharam suresh
how much they are offering ? Thank you, Siddharam On Tue, Aug 23, 2011 at 11:12 AM, ranjith kumar wrote: > > > They shortlist candidates based on cgpa and select the highest cgpa > candidate. > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" g

Re: [algogeeks] Re: C dot

2011-08-22 Thread ranjith kumar
They shortlist candidates based on cgpa and select the highest cgpa candidate. -- 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 alg

Re: [algogeeks] Re: c question what is output?

2011-08-21 Thread Dipankar Patro
+1 to 16. whats the confusion here? On 21 August 2011 16:44, sagar pareek wrote: > Arey yaar just see the my post... > i explained it step by step :) > > > On Sun, Aug 21, 2011 at 4:43 PM, Sanjay Rajpal wrote: > >> 16 >> >> 8*(8-1*(8-1-1)) >> >> >> Sanju >> :) >> >> >> >> On Sun, Aug 21, 2011

Re: [algogeeks] Re: c question what is output?

2011-08-21 Thread sagar pareek
Arey yaar just see the my post... i explained it step by step :) On Sun, Aug 21, 2011 at 4:43 PM, Sanjay Rajpal wrote: > 16 > > 8*(8-1*(8-1-1)) > > > Sanju > :) > > > > On Sun, Aug 21, 2011 at 4:10 AM, Anjul Sharma wrote: > >> is 336 the answer?? >> >> On Aug 21, 11:10 am, SuDhir mIsHra wrote:

Re: [algogeeks] Re: c question what is output?

2011-08-21 Thread Sanjay Rajpal
16 8*(8-1*(8-1-1)) Sanju :) On Sun, Aug 21, 2011 at 4:10 AM, Anjul Sharma wrote: > is 336 the answer?? > > On Aug 21, 11:10 am, SuDhir mIsHra wrote: > > #include > > #define FUNC1(i) (i*(i-1)) > > #define FUNC2(i) (i==0?1:i*FUNC1(i-1)) > > main() > > { > > int i=8; > > > > p

[algogeeks] Re: c question what is output?

2011-08-21 Thread Anjul Sharma
is 336 the answer?? On Aug 21, 11:10 am, SuDhir mIsHra wrote: > #include > #define FUNC1(i) (i*(i-1)) > #define FUNC2(i) (i==0?1:i*FUNC1(i-1)) > main() > { >         int i=8; > >         printf("\n%d",FUNC2(i)); > > > > > > > > } -- You received this message because you are subscribed to the Go

Re: [algogeeks] Re: C dot

2011-08-20 Thread aditi garg
Thnks:) On Sat, Aug 20, 2011 at 1:00 AM, sachin sabbarwal wrote: > they ask very easy questions in interviews. > i had faced their interview. > first of all they asked me if i had done any project work. > then they asked about the platform used and why i had chosen it. > then few easy questions a

[algogeeks] Re: C dot

2011-08-19 Thread sachin sabbarwal
they ask very easy questions in interviews. i had faced their interview. first of all they asked me if i had done any project work. then they asked about the platform used and why i had chosen it. then few easy questions about algo of the project. they questioned me on bubble sort. then i was aske

Re: [algogeeks] Re: C output

2011-08-17 Thread rajeev bharshetty
No the warning in gcc is ibm1.c: In function ‘main’: ibm1.c:7:19: warning: initialization discards qualifiers from pointer target type On Wed, Aug 17, 2011 at 11:50 AM, venkat wrote: > yes u r correct > > On Aug 16, 8:22 pm, Sanjay Rajpal wrote: > > This is becuase "Hello" is a constant strin

[algogeeks] Re: C output

2011-08-16 Thread venkat
yes u r correct On Aug 16, 8:22 pm, Sanjay Rajpal wrote: > This is becuase "Hello" is a constant string and constant strings get stored > in *Data Area, not in stack for the function you called. *Thats why pointer > to constant string will be returned and program will not produce any error. > > S

[algogeeks] Re: c output

2011-08-16 Thread roopesh bajaj
it is compiler dependent On Aug 1, 5:20 pm, thanu moorthy wrote: > Please help me... > > How can the following output be obtained : > >  1.main() > > { > >  int i=1; > > printf("%d\t%d\t%d\t",i,i++,i); > > } > > output: 2 1 2 > >  2.main() > > { > >  int i=1; > > printf("%d\t%d\t%d\t",i,++i,i); >

[algogeeks] Re: c output doubt

2011-08-14 Thread roopesh bajaj
what is the logic of your concept On Aug 13, 5:01 pm, Kunal Patil wrote: > @rohit: Cast pointer to an integer into an int to get what you are > expecting. > > for e.g. > > printf("%d",(int)&a[4]-(int)&a[0]); > > This will give 16. -- You received this message because you are subscribed to the G

Re: [algogeeks] Re: C Output

2011-08-13 Thread sourabh jakhar
compiler dependent and will print some address On Sun, Aug 14, 2011 at 11:48 AM, sukran dhawan wrote: > try out with Microsoft VC++ > > > On Sun, Aug 14, 2011 at 11:47 AM, Brijesh Upadhyay < > brijeshupadhyay...@gmail.com> wrote: > >> I think i got it... "STRING" always return address of S , whi

Re: [algogeeks] Re: C Output

2011-08-13 Thread sukran dhawan
try out with Microsoft VC++ On Sun, Aug 14, 2011 at 11:47 AM, Brijesh Upadhyay < brijeshupadhyay...@gmail.com> wrote: > I think i got it... "STRING" always return address of S , which then get > summed with 1 and 2. > > -- > You received this message because you are subscribed to the Google Grou

[algogeeks] Re: C Output

2011-08-13 Thread Brijesh Upadhyay
I think i got it... "STRING" always return address of S , which then get summed with 1 and 2. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/kFrZUxzFTxsJ

Re: [algogeeks] Re: c output doubt

2011-08-13 Thread Kunal Patil
@rohit: Cast pointer to an integer into an int to get what you are expecting. for e.g. printf("%d",(int)&a[4]-(int)&a[0]); This will give 16. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@go

  1   2   3   >