Re: [algogeeks] C output

2012-10-17 Thread Vikas Kumar
#includestdio.h int main() { char str[]={'a','b','c'}; char str1[]={abc}; printf(%d,sizeof(str)); printf(%d,sizeof(str1)); getchar(); } This is giving 3 in case of str and 4 in case of str1 bcz str is array of character and str1 is a string. For understanding this point

Re: [algogeeks] C output

2012-10-08 Thread Sachin
@rahul According to C specification, half filled array will be filled with value 0. In your example you are setting str[0] as 'g' and str[1] as 'k'. So the compiler sets str[29] as 0. So you string str becomes {'g', 'k', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0'} Confusion is arising

Re: [algogeeks] C output

2012-10-08 Thread rahul sharma
@sachin..thnx for explanation..got it..plz tell #includestdio.h int main() { char str[]={'a','b','c'}; char str1[]={abc}; printf(%d,sizeof(str)); printf(%d,sizeof(str1)); getchar(); } why str has size 3 and str1 has 4...NUll should also come after c of str???then y

[algogeeks] C output

2012-10-06 Thread rahul sharma
char str[]=ab; char str1[]={'a','b'}; sizeof(str) ...o/p is 3 sizeof(str1)o/p is 2.. Why so 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

Re: [algogeeks] C output

2012-10-06 Thread Jaspreet Singh
because of null char in 1st On Sat, Oct 6, 2012 at 5:53 PM, rahul sharma rahul23111...@gmail.comwrote: char str[]=ab; char str1[]={'a','b'}; sizeof(str) ...o/p is 3 sizeof(str1)o/p is 2.. Why so plz explain...-- You received this message because you are subscribed to the Google

Re: [algogeeks] C output

2012-10-06 Thread Rathish Kannan
For string, C appends '\0' internally. hence sizeof(str) returned the value 3. str1 is char array with two character. hence sizeof(str1) returned the value 2. -- RK :) On Sat, Oct 6, 2012 at 5:53 PM, rahul sharma rahul23111...@gmail.comwrote: char str[]=ab; char str1[]={'a','b'};

Re: [algogeeks] C output

2012-10-06 Thread rahul sharma
int main() { char str[10]={'g','k'}; char str1[10]=gh; printf(%s,str); printf(%s,str1); getchar(); } then how does this work??? str printing gk...then NULL is automatically appended in this also...plz tell On Sat, Oct 6, 2012 at 6:33 PM, Rathish Kannan

Re: [algogeeks] C output

2012-10-06 Thread rahul sharma
#includestdio.h int main() { char str[10]={'g','k'}; char str1[10]=gh; int i; for(i=0;str1[i]!=NULL;i++) printf(%c,str[i]); getchar(); } NUll is there in character array also...make clear me... On Sat, Oct 6, 2012 at 9:22 PM, rahul sharma rahul23111...@gmail.comwrote: int

Re: [algogeeks] C output

2012-07-03 Thread atul anand
violation of sequence point ruleoutput depends on compiler to compiler. On Tue, Jul 3, 2012 at 1:22 PM, rahul sharma rahul23111...@gmail.comwrote: #includestdio.h #includeconio.h int main() { int i; i=5; i=++i/i++; printf(%d,i); getch(); } Why o/p is 1 and not

[algogeeks] c output

2012-01-16 Thread dabbcomputers
#includestdio.h int main() { double p=fabs(24.9996); double t=fabs(25.0003); printf(%0.3lf %0.3lf\n,p,t); if(fabs(p)==fabs(t)) printf(equal);// why this not executed? } why the equal not printed in this code...? -- You received this message because you are subscribed to the

Re: [algogeeks] c output

2012-01-16 Thread atul anand
printf(%0.3lf %0.3lf\n,p,t); its just printing at your convenience . you are not changing the value of p,t . change this statement to printf(%0.5lf %0.5lf\n,p,t); On Tue, Jan 17, 2012 at 11:27 AM, dabbcomputers dabbcomput...@gmail.comwrote: #includestdio.h int main() { double

Re: [algogeeks] c output

2012-01-16 Thread shady
atul he is assigning the value later on. i think format specifier . rounds up the number in last decimal place. On Tue, Jan 17, 2012 at 11:53 AM, atul anand atul.87fri...@gmail.comwrote: printf(%0.3lf %0.3lf\n,p,t); its just printing at your convenience . you are not changing the value of

Re: [algogeeks] c output

2012-01-16 Thread Rujin Cao
It's not a good way to compare two floats directly using =, try something like below: http://ideone.com/c65Vl -- 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

Re: [algogeeks] c output

2012-01-16 Thread payal gupta
i gues atul is crkt. its jst printin by user convenience...when actually d two are not equal... i guess the code...xplains well...dats y equal is not printed..out #includestdio.hint main(){ double p=fabs(24.9996); printf(%lf\n,p); double t=fabs(25.0003); printf(%lf\n,t);

Re: [algogeeks] c output ??

2012-01-10 Thread Rahul Verma
@amol this is not the behaviour of printf, its totally about the typecasting -- 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/-/GPVlt15S3V0J. To post to this

Re: [algogeeks] c output ??

2012-01-10 Thread saurabh singh
It's painful to see printf being accused for the (un) expected output..The declaration of printf means that any data type can be passed to it as argument.Inherently what printf does is print the bytes in meaningful form according to the first argument which is a string.So its impossible for

Re: [algogeeks] c output ??

2012-01-09 Thread Amol Sharma
According to KR the behavior of printf is undefined if u do not use correct format specifiers for the variables. -- Amol Sharma Third Year Student Computer Science and Engineering MNNIT Allahabad http://gplus.to/amolsharma99

Re: [algogeeks] c output ??

2012-01-09 Thread Kartik Sachan
@amol I think it is not the behaviour of printf -- 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] c output ??

2012-01-08 Thread HARSHIT PAHUJA
*#includestdio.h int main() { float f=25.25; printf(%d\n,f); long int x=90; printf(%f,x); return 0; } * above program gives output *0 25.25* shudn it be : *25 90.* ?? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this

Re: [algogeeks] c output ??

2012-01-08 Thread atul anand
take care when ever you use %d and %f %d is not flexible in handling float varibaledo not expect it to typecast itself. reason could be , you are trying to fit large data type i.e float to the int whose range is less. whereas in second case float can incorporate int type , so automatic

Re: [algogeeks] C output????

2012-01-06 Thread sravanreddy001
@arun: http://mindprod.com/jgloss/immutable.html this might help you, in essense, if a compiler treats them as immutable, the reason is to reduce the overhead of creating another contant literal (as explain at the link, the string literals are the most commonly used) this is from a java (or

Re: [algogeeks] C output????

2012-01-05 Thread teja bala
depends on compiler i think..but most probably it compares the addresses. On Wed, Jan 4, 2012 at 12:20 PM, saurabh singh saurab...@gmail.com wrote: @all.Your explanations work because probably all of you are using a compiler that's behaving in the same way.Don't conclude from what

Re: [algogeeks] C output????

2012-01-03 Thread Arun Vishwanathan
actually is there any reason as to why same address is returned to the pointer when both pointers(p and q) are initialised to persons unlike when p[] and q[] =persons? On Tue, Sep 6, 2011 at 9:08 AM, Sandy sandy.wad...@gmail.com wrote: String constants (literals) are saved into the .data

Re: [algogeeks] C output????

2012-01-03 Thread Rahul
it's near to a common mis conception that string liberals are in data sections of THE PROGRAM PLEASE READ THE FILE a.out.h and find the difference between initialized data and non initialized data On 9/6/11, Sandy sandy.wad...@gmail.com wrote: String constants (literals) are saved into the

Re: [algogeeks] C output????

2012-01-03 Thread saurabh singh
@all.Your explanations work because probably all of you are using a compiler that's behaving in the same way.Don't conclude from what you see...The compiler is free to store the constant strings the way it wants. Saurabh Singh B.Tech (Computer Science) MNNIT

Re: [algogeeks] c output

2011-10-29 Thread rahul sharma
does y goes to d of %*d and it print 5???i hav a doubt On Fri, Oct 28, 2011 at 9:32 PM, amrit harry dabbcomput...@gmail.comwrote: let this statement int x=100,y=5;printf(%*d,x,y); in this line first x is assign to '*' and it become %100d and it will padd 100 spaces before print. and if we

Re: [algogeeks] c output

2011-10-29 Thread Anika Jain
yes 5 will be printed with 99 extra padding spaces. On Sat, Oct 29, 2011 at 4:16 PM, rahul sharma rahul23111...@gmail.comwrote: does y goes to d of %*d and it print 5???i hav a doubt On Fri, Oct 28, 2011 at 9:32 PM, amrit harry dabbcomput...@gmail.comwrote: let this statement int

Re: [algogeeks] c output

2011-10-28 Thread annarao kataru
can u plz tell me what exactly %*d means? -- 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] c output

2011-10-28 Thread amrit harry
let this statement int x=100,y=5;printf(%*d,x,y); in this line first x is assign to '*' and it become %100d and it will padd 100 spaces before print. and if we use( %*d,x) then x is assign to '*' and garbage value wud be printed. On Fri, Oct 28, 2011 at 8:53 PM, annarao kataru

[algogeeks] c output

2011-10-08 Thread Raghav Garg
*explain the o/p...if i/p are 100 200 300 int main() { int a=1,b=2,c=3; scanf(%d %*d %d,a,b,c); printf(%d %d %d,a,b,c); return(0); } *Thanking you *With regards- Raghav garg Contact no. 9013201944

Re: [algogeeks] c output

2011-10-08 Thread shiva@Algo
as expected value 100 goes to a,since %*d is variable field width specifier so the input 200 goes for that,and the remaining input 300 goes to b value of c is not change so the output will be: 100 300 3 On Sun, Oct 9, 2011 at 12:22 AM, Raghav Garg rock.ragha...@gmail.comwrote: *explain the

Re: [algogeeks] c output

2011-10-08 Thread shiva@Algo
This is what you use if you want *scanf()* to eat some data but you don't want to store it anywhere; you don't give *scanf()* an argument for this conversion On Sun, Oct 9, 2011 at 1:32 AM, shiva@Algo shiv.jays...@gmail.com wrote: as expected value 100 goes to a,since %*d is variable field

Re: [algogeeks] C OUTPUT

2011-09-22 Thread Pradip Singh
number will be sored in 2'scomplement form .as 4=100 so its 1's comlement form will be 011 and adding 1 to it will result in 011+1=100.so -4 will be printed On Wed, Sep 21, 2011 at 10:23 AM, kartik sachan kartik.sac...@gmail.comwrote: @ravi i think ur concepts is correct the no is stored in

[algogeeks] C OUTPUT

2011-09-21 Thread kartik sachan
int main(){ struct { int a:1; int b:3; }obj; obj.b=12; obj.a=7; printf http://www.opengroup.org/onlinepubs/009695399/functions/printf.html(%d %d,obj.b,obj.a);return 0;} can anybody explain the output plzz also show

Re: [algogeeks] C OUTPUT

2011-09-21 Thread ravi maggon
output is -4 -1 int a:1 signifies that only 1 bit will be stored for a and since we have only 1 bit so it will serve as sign bit and we get obj.a as -1 similarly for int b:3, 3 bits will be used to store b. 12 is 1100. we save only 3 bits i.e. 100 where msb signifies the sign i.e. no. is negative.

Re: [algogeeks] C OUTPUT

2011-09-21 Thread kartik sachan
@ravi i think ur concepts is correct the no is stored in 2's formif negative thanks ravi -- 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,

Re: [algogeeks] c output

2011-09-19 Thread Siddhartha Banerjee
on running,every time i get second a=30... any reasons for that??? -- 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] c output

2011-09-19 Thread sukran dhawan
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 time i get second a=30... any reasons for that??? -- You received this message because you are subscribed to the Google Groups

[algogeeks] c output

2011-09-18 Thread hurtlocker
#includestdio.h main() { int a ; a=abc(); printf(\n %d this is fisrt a:,a); a=abc(); printf(\n %d this is second a:,a); } int abc() { int i=23; if(10) return ; i++; return(++ i); } -- You received this message because you are subscribed

[algogeeks] c output

2011-09-18 Thread Bhavesh agrawal
#includestdio.h main() { int a ; a=abc(); printf(\n %d this is fisrt a:,a); a=abc(); printf(\n %d this is second a:,a); } int abc() { int i=23; if(10) return ; i++; return(++ i); } -- You received this message because you are subscribed

Re: [algogeeks] c output

2011-09-18 Thread sukran dhawan
result is not defined by standard c. It doesnt produce compiler error just because return type is int and no value is returned in if(10) basically garbage On Sun, Sep 18, 2011 at 12:23 PM, Bhavesh agrawal agr.bhav...@gmail.comwrote: #includestdio.h main() { int a ; a=abc();

Re: [algogeeks] c output

2011-09-18 Thread Amol Sharma
it is just printing some garbage value as u have specified return but not the value.try putting some value with return then you'll understand what's happening.. -- Amol Sharma Third Year Student Computer Science and Engineering MNNIT Allahabad http://gplus.to/amolsharma99

Re: [algogeeks] c output

2011-09-18 Thread kartik sachan
@what's special in this ... it is giving 0 in both cases. basically a garbage 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. To unsubscribe from this group,

Re: [algogeeks] c output

2011-09-18 Thread Bhavesh agrawal
result is this -1075990972 this is fisrt a: 30 this is second a what is the meaning of a=30 in second call -- 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

Re: [algogeeks] c output

2011-09-18 Thread Anup Ghatage
Error. the 10 condition does not return anything, while the function should return an int. On Sun, Sep 18, 2011 at 6:39 AM, hurtlocker bhavesh24...@rediffmail.comwrote: #includestdio.h main() { int a ; a=abc(); printf(\n %d this is fisrt a:,a); a=abc();

Re: [algogeeks] c output

2011-09-18 Thread Saravana kumar
0 this is fisrt a: 0 this is second a: On Sun, Sep 18, 2011 at 12:09 PM, hurtlocker bhavesh24...@rediffmail.comwrote: #includestdio.h main() { int a ; a=abc(); printf(\n %d this is fisrt a:,a); a=abc(); printf(\n %d this is second a:,a); } int abc() {

Re: [algogeeks] c output

2011-09-18 Thread Bhavesh agrawal
another que.. #includestdio.h main() { int a; int i=10; printf(%d %d %d\n,i+++i,i,i---i); printf(%d\n,i---i); a=i---i; printf(%d \n%d,a,i); return 0; } output: 18 10 0 0 0 8 how ?? -- You received this message because you are subscribed to the Google Groups

Re: [algogeeks] c output

2011-09-18 Thread sukran dhawan
again undefined in standard c :) On Sun, Sep 18, 2011 at 1:49 PM, Bhavesh agrawal agr.bhav...@gmail.comwrote: another que.. #includestdio.h main() { int a; int i=10; printf(%d %d %d\n,i+++i,i,i---i); printf(%d\n,i---i); a=i---i; printf(%d \n%d,a,i);

[algogeeks] c output,printf(%llx)

2011-09-18 Thread wujin chen
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~~ can anyone explain it? thanks. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this

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

2011-09-18 Thread sagar pareek
Check out what u have written... On Sun, Sep 18, 2011 at 7:17 PM, wujin chen wujinchen...@gmail.com 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~~ can anyone explain it? thanks.

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

2011-09-18 Thread wujin chen
sorry , it should be : usigned long long c = 0x12345678; int a = 0x09; int b = 0x10; printf(a=%x, b=%llx,a,b,c); 2011/9/19 sagar pareek sagarpar...@gmail.com Check out what u have written... On Sun, Sep 18, 2011 at 7:17 PM, wujin chen wujinchen...@gmail.comwrote: usigned long long x =

Re: [algogeeks] C output

2011-09-14 Thread tech coder
+1 On Wed, Aug 31, 2011 at 9:27 PM, SANDEEP CHUGH sandeep.aa...@gmail.comwrote: its 4 3 i think On Wed, Aug 31, 2011 at 9:25 PM, aditi garg aditi.garg.6...@gmail.comwrote: 8 3 On Wed, Aug 31, 2011 at 9:22 PM, rohit raman.u...@gmail.com wrote: output?? int main() { char *d =

Re: [algogeeks] C output

2011-09-14 Thread tech coder
for 16 bit compiler ans is 2 3 for 32 bit compiler ans is 4 3 pls correct me if i m wrong On Wed, Sep 14, 2011 at 11:36 AM, tech coder techcoderonw...@gmail.comwrote: +1 On Wed, Aug 31, 2011 at 9:27 PM, SANDEEP CHUGH sandeep.aa...@gmail.comwrote: its 4 3 i think On Wed, Aug 31, 2011

Re: [algogeeks] C output

2011-09-14 Thread Rohit Upadhyaya
for a 32 bit it is 4 ,3 and for 16 bit it is 2,3 and 64 bit it is 8,3.. also strlen(d) gives 3 bcz the coding of fn strlen() is such that as it encounters null it will terminate..so irrespective of machine it prints 3 as null at 4th place -- You received this message because you are subscribed

Re: [algogeeks] C output

2011-09-14 Thread PRATEEK VERMA
9 and 3 -- 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

Re: [algogeeks] C output

2011-09-14 Thread tech coder
@ prateek absolutely wrong , dear u need to brushup ur basics d is a pointer , it's can be 2 or 4 depebding on compiler On Wed, Sep 14, 2011 at 6:26 AM, PRATEEK VERMA prateek...@gmail.com wrote: 9 and 3 -- You received this message because you are subscribed to the Google Groups Algorithm

[algogeeks] C output????

2011-09-06 Thread sivaviknesh s
main() { char *p=persons; clrscr(); if(p==persons) printf(technical %s,p); else printf(true %s,p); return 0; } ..op : technical persons ..plz explain .. how come it works like an strcmp operation??? -- Regards, $iva -- You received this message because you are subscribed to the Google Groups

Re: [algogeeks] C output????

2011-09-06 Thread Shravan Kumar
String literals are saved into a separate table in compiler. So second time when you define persons it wont be created or allocated memory as it already exists in table. On Tue, Sep 6, 2011 at 9:04 PM, sivaviknesh s sivavikne...@gmail.comwrote: main() { char *p=persons; clrscr();

Re: [algogeeks] C output????

2011-09-06 Thread aditi garg
It is basically comparing the addresses of the two and since p contains the memory address of persons it gives the output as technical persons... infact ull be surprised to see dis #includestdio.h main(){char p[]=persons;char q[]=persons;if(p==q)printf

Re: [algogeeks] C output????

2011-09-06 Thread Dheeraj Sharma
in case of constant strings..they all return the same pointer..where they are defined.. but in case of non constant strings..like a[]=sumthing and b[]=sumthing...they will have separate memory allocations.. On Tue, Sep 6, 2011 at 9:12 PM, aditi garg aditi.garg.6...@gmail.comwrote: It is

Re: [algogeeks] C output????

2011-09-06 Thread sukran dhawan
addresses are compared here i think On Tue, Sep 6, 2011 at 9:04 PM, sivaviknesh s sivavikne...@gmail.comwrote: main() { char *p=persons; clrscr(); if(p==persons) printf(technical %s,p); else printf(true %s,p); return 0; } ..op : technical persons ..plz explain .. how come it works

Re: [algogeeks] C output????

2011-09-06 Thread Sandy
String constants (literals) are saved into the .data section of the program, Here is the sample program to show that. if() is essentially comparing the addresses of two pointers which is same. int main() { char *p=persons; char *q=persons; char *r=persons; char *s=persons; printf(%x %x %x

[algogeeks] c output .. help plz

2011-09-06 Thread sivaviknesh s
printf(%d,3.14*6.25*6.25); ...ans : 0 ..how and why?? why not type conversion take place?? -- Regards, $iva -- 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

Re: [algogeeks] c output .. help plz

2011-09-06 Thread sukran dhawan
it wil not truncate the floating point to integer remember... On Tue, Sep 6, 2011 at 9:55 PM, sivaviknesh s sivavikne...@gmail.comwrote: printf(%d,3.14*6.25*6.25); ...ans : 0 ..how and why?? why not type conversion take place?? -- Regards, $iva -- You received this message because you

Re: [algogeeks] c output .. help plz

2011-09-06 Thread sukran dhawan
coz both floating point are stored in ieee format which is different from integers On Tue, Sep 6, 2011 at 10:18 PM, sukran dhawan sukrandha...@gmail.comwrote: it wil not truncate the floating point to integer remember... On Tue, Sep 6, 2011 at 9:55 PM, sivaviknesh s

Re: [algogeeks] C output

2011-09-01 Thread sukran dhawan
9 and 3 On Wed, Aug 31, 2011 at 9:22 PM, rohit raman.u...@gmail.com wrote: output?? int main() { char *d = abc\0def\0; printf(%d %d,sizeof(d),strlen(d)); getch(); } -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view

Re: [algogeeks] C output

2011-09-01 Thread sukran dhawan
sizeof considers everything between double quotes + /0 character strlen reads until first \0 On Thu, Sep 1, 2011 at 5:49 PM, sukran dhawan sukrandha...@gmail.comwrote: 9 and 3 On Wed, Aug 31, 2011 at 9:22 PM, rohit raman.u...@gmail.com wrote: output?? int main() { char *d = abc\0def\0;

Re: [algogeeks] C output

2011-09-01 Thread Anil Arya
output is machine dependent. On 9/1/11, sukran dhawan sukrandha...@gmail.com wrote: sizeof considers everything between double quotes + /0 character strlen reads until first \0 On Thu, Sep 1, 2011 at 5:49 PM, sukran dhawan sukrandha...@gmail.comwrote: 9 and 3 On Wed, Aug 31, 2011 at 9:22

Re: [algogeeks] C output

2011-08-31 Thread SANDEEP CHUGH
its 4 3 i think On Wed, Aug 31, 2011 at 9:25 PM, aditi garg aditi.garg.6...@gmail.comwrote: 8 3 On Wed, Aug 31, 2011 at 9:22 PM, rohit raman.u...@gmail.com wrote: output?? int main() { char *d = abc\0def\0; printf(%d %d,sizeof(d),strlen(d)); getch(); } -- You received

Re: [algogeeks] C output

2011-08-31 Thread sachin goyal
2 3 because d is pointer avriable On Wed, Aug 31, 2011 at 9:25 PM, aditi garg aditi.garg.6...@gmail.comwrote: 8 3 On Wed, Aug 31, 2011 at 9:22 PM, rohit raman.u...@gmail.com wrote: output?? int main() { char *d = abc\0def\0; printf(%d %d,sizeof(d),strlen(d)); getch(); } --

Re: [algogeeks] C output

2011-08-31 Thread SANDEEP CHUGH
i said 4 3 according to 32 bit machine.. if its 16 bit thn it wud be 2 3 On Wed, Aug 31, 2011 at 9:30 PM, sachin goyal monugoya...@gmail.com wrote: 2 3 because d is pointer avriable On Wed, Aug 31, 2011 at 9:25 PM, aditi garg aditi.garg.6...@gmail.comwrote: 8 3 On Wed, Aug 31, 2011 at

Re: [algogeeks] C output

2011-08-31 Thread rahul vatsa
sizeof(d) is the sz of pointer, so depending on arch it will be 4 or 8 ... On Wed, Aug 31, 2011 at 11:57 AM, SANDEEP CHUGH sandeep.aa...@gmail.comwrote: its 4 3 i think On Wed, Aug 31, 2011 at 9:25 PM, aditi garg aditi.garg.6...@gmail.comwrote: 8 3 On Wed, Aug 31, 2011 at 9:22 PM,

Re: [algogeeks] C output

2011-08-31 Thread aditi garg
sorry my mistake... it wud be 4 3 On Wed, Aug 31, 2011 at 9:30 PM, sachin goyal monugoya...@gmail.com wrote: 2 3 because d is pointer avriable On Wed, Aug 31, 2011 at 9:25 PM, aditi garg aditi.garg.6...@gmail.comwrote: 8 3 On Wed, Aug 31, 2011 at 9:22 PM, rohit raman.u...@gmail.com

Re: [algogeeks] C output

2011-08-31 Thread Dheeraj Sharma
8 3 is correct..winshuttle mein aaya tha ;) On Wed, Aug 31, 2011 at 9:30 PM, aditi garg aditi.garg.6...@gmail.comwrote: No sizeof ignores \0 On Wed, Aug 31, 2011 at 9:27 PM, SANDEEP CHUGH sandeep.aa...@gmail.comwrote: its 4 3 i think On Wed, Aug 31, 2011 at 9:25 PM, aditi garg

Re: [algogeeks] C output

2011-08-31 Thread annarao kataru
yes it must be 4 3 -- 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] C output

2011-08-31 Thread aditi garg
@dheeraj yea true,,,bt ut ws an array...its a pointer here...so output will be 4 3... infact it wud be 9 3 in the case u r considering On Wed, Aug 31, 2011 at 9:32 PM, Dheeraj Sharma dheerajsharma1...@gmail.com wrote: 8 3 is correct..winshuttle mein aaya tha ;) On Wed, Aug 31, 2011 at 9:30

Re: [algogeeks] C output

2011-08-31 Thread SANDEEP CHUGH
8 3 wud the answer if you use the following syntax int main() { char d[] = abc\0def\0; printf(%d %d,sizeof(d),strlen(d)); getch(); } as you are using char *d so sizeof will print only size of pointer variable On Wed, Aug 31, 2011 at 9:32 PM, Dheeraj Sharma dheerajsharma1...@gmail.com

Re: [algogeeks] C output

2011-08-31 Thread SANDEEP CHUGH
+1 aditi On Wed, Aug 31, 2011 at 9:34 PM, aditi garg aditi.garg.6...@gmail.comwrote: @dheeraj yea true,,,bt ut ws an array...its a pointer here...so output will be 4 3... infact it wud be 9 3 in the case u r considering On Wed, Aug 31, 2011 at 9:32 PM, Dheeraj Sharma

Re: [algogeeks] C output

2011-08-31 Thread Dheeraj Sharma
for this char *d = abc\ldef\l; the output is 4 8 not 4 9 \l treated as one character On Wed, Aug 31, 2011 at 9:34 PM, aditi garg aditi.garg.6...@gmail.comwrote: @dheeraj yea true,,,bt ut ws an array...its a pointer here...so output will be 4 3... infact it wud be 9 3 in the case u r

Re: [algogeeks] C output

2011-08-31 Thread aditi garg
8 3 On Wed, Aug 31, 2011 at 9:22 PM, rohit raman.u...@gmail.com wrote: output?? int main() { char *d = abc\0def\0; printf(%d %d,sizeof(d),strlen(d)); getch(); } -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this

Re: [algogeeks] C output

2011-08-31 Thread Swathi
Depends on the 32-bit or 64-bit... sizeof(d) - returns the 4 in case of 32-bit, 8 incase of 64-bit strlen(d) - 3 On Wed, Aug 31, 2011 at 9:32 PM, Dheeraj Sharma dheerajsharma1...@gmail.com wrote: 8 3 is correct..winshuttle mein aaya tha ;) On Wed, Aug 31, 2011 at 9:30 PM, aditi garg

[algogeeks] C output

2011-08-22 Thread rohit
#includestdio.h #define max(a,b) (ab?a:b) int main() { int j=max(3+2,2+8); printf(%d,j); return 0; } why this program show output as 9 ? please help me -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group,

Re: [algogeeks] C output

2011-08-22 Thread Deepak Garg
its output is 10 On Tue, Aug 23, 2011 at 12:03 AM, rohit rajuljain...@gmail.com wrote: #includestdio.h #define max(a,b) (ab?a:b) int main() { int j=max(3+2,2+8); printf(%d,j); return 0; } why this program show output as 9 ? please help me -- You received this

Re: [algogeeks] C output

2011-08-22 Thread sagar pareek
Yeah its o/p is 10 :) On Tue, Aug 23, 2011 at 12:45 AM, Deepak Garg deepakgarg...@gmail.comwrote: its output is 10 On Tue, Aug 23, 2011 at 12:03 AM, rohit rajuljain...@gmail.com wrote: #includestdio.h #define max(a,b) (ab?a:b) int main() { int j=max(3+2,2+8); printf(%d,j);

Re: [algogeeks] C output

2011-08-22 Thread gmagog...@gmail.com
output is 10 using gcc 4.5.2 Yanan Cao On Mon, Aug 22, 2011 at 2:18 PM, sagar pareek sagarpar...@gmail.com wrote: Yeah its o/p is 10 :) On Tue, Aug 23, 2011 at 12:45 AM, Deepak Garg deepakgarg...@gmail.comwrote: its output is 10 On Tue, Aug 23, 2011 at 12:03 AM, rohit

Re: [algogeeks] C output

2011-08-22 Thread code pool
10 as 3+22+8?3+2:2+8 510?5:10 ' + ' has more precedence then ?: as well as s o/p is 10.. correct me if i am wrong. On Tue, Aug 23, 2011 at 12:50 AM, gmagog...@gmail.com gmagog...@gmail.comwrote: output is 10 using gcc 4.5.2 Yanan Cao On Mon, Aug 22, 2011 at 2:18 PM, sagar pareek

Re: [algogeeks] C output

2011-08-22 Thread sukran dhawan
its 10 On Tue, Aug 23, 2011 at 12:03 AM, rohit rajuljain...@gmail.com wrote: #includestdio.h #define max(a,b) (ab?a:b) int main() { int j=max(3+2,2+8); printf(%d,j); return 0; } why this program show output as 9 ? please help me -- You received this message because

[algogeeks] C output

2011-08-16 Thread rohit
#includestdio.hconst char *fun(); int main() { char *ptr = fun(); return 0; }const char *fun() { return Hello; } Why doesn't this code give error?? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the

Re: [algogeeks] C output

2011-08-16 Thread Sanjay Rajpal
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. Sanjay Kumar B.Tech Final Year Department of Computer Engineering

Re: [algogeeks] C output

2011-08-16 Thread himanshu kansal
i think this must have produced a warning..conversion from const char * to char*... On Tue, Aug 16, 2011 at 8:52 PM, Sanjay Rajpal sanjay.raj...@live.inwrote: This is becuase Hello is a constant string and constant strings get stored in *Data Area, not in stack for the function you

[algogeeks] C Output

2011-08-14 Thread Brijesh Upadhyay
int main () { printf(%d,1+2+5); getch(); return 0; } what should it return and how..?? -- 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/-/2H3Gg6hLEQ0J.

Re: [algogeeks] C Output

2011-08-14 Thread sukran dhawan
i got a warning in gcc and the output was garbage On Sun, Aug 14, 2011 at 11:44 AM, Brijesh Upadhyay brijeshupadhyay...@gmail.com wrote: int main () { printf(%d,1+2+5); getch(); return 0; } what should it return and how..?? -- You received this message because you are

Re: [algogeeks] C Output

2011-08-14 Thread Ankur Khurana
5 will represent address of 5 in heap. so adding 3 to 5 increment tht address by 3 and print it on the screen On Sun, Aug 14, 2011 at 11:44 AM, Brijesh Upadhyay brijeshupadhyay...@gmail.com wrote: int main () { printf(%d,1+2+5); getch(); return 0; } what should it return and

Re: [algogeeks] C Output

2011-08-14 Thread rahul aravind
I think the address of string 5 located will be added with 1 and 2... On Sun, Aug 14, 2011 at 11:44 AM, Brijesh Upadhyay brijeshupadhyay...@gmail.com wrote: int main () { printf(%d,1+2+5); getch(); return 0; } what should it return and how..?? -- You received this message

[algogeeks] c output doubt

2011-08-12 Thread rohit
int main() { int a[5]={1,2,3,4,5}; printf(%d,a[4]-a[0]) } why it show 4 not 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@googlegroups.com. To unsubscribe from this group, send email to

Re: [algogeeks] c output doubt

2011-08-12 Thread Avinash Dharan
Pointer incrementation and subtraction are done in terms of memory blocks and not addresses of memory. For example, int *p; p++; The pointer here jumps to the next integer location and not the next address in memory. Similarly,pointer subtraction will give the difference in indexes and not the

Re: [algogeeks] c output doubt

2011-08-12 Thread Varun Jakhoria
i didn't tried it .. but it might be internal conversion only , like whenever we do +1 to the address of int it automatically convert it into +4(i.e int size) On Fri, Aug 12, 2011 at 11:34 AM, rohit rajuljain...@gmail.com wrote: int main() { int a[5]={1,2,3,4,5}; printf(%d,a[4]-a[0]) }

Re: [algogeeks] c output doubt

2011-08-12 Thread siddharam suresh
4*(sizeof(int *)) Thank you, Siddharam On Fri, Aug 12, 2011 at 11:56 AM, Varun Jakhoria varunjakho...@gmail.comwrote: i didn't tried it .. but it might be internal conversion only , like whenever we do +1 to the address of int it automatically convert it into +4(i.e int size) On Fri, Aug

Re: [algogeeks] c output doubt

2011-08-12 Thread Avinash Dharan
On Fri, Aug 12, 2011 at 11:55 AM, Avinash Dharan avinashdha...@gmail.comwrote: Pointer incrementation and subtraction are done in terms of memory blocks and not addresses of memory. For example, int *p; p++; The pointer here jumps to the next integer location and not the next address in

[algogeeks] c output

2011-08-10 Thread rohit
main() { int m,n; m=3+max(2,3); n=2*max(3,2); printf(“%d,%d”,m,n); } ans:-m=2,n=3 why output is this??? -- 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

  1   2   3   >