Re: [algogeeks] C OUTPUT HELP

2011-07-12 Thread nicks
@anandregarding problem 2 i agree with you and observed the samebut that gives me the feel that the compiler in working in the interprating manner though it doesn't...btw thanks for pointing it out. and in problem 3 what i understood after reading with what you wrote is that size

Re: [algogeeks] C OUTPUT HELP

2011-07-12 Thread Anand Saha
On Tue, Jul 12, 2011 at 2:36 PM, nicks crazy.logic.k...@gmail.com wrote: and in problem 3 what i understood after reading with what you wrote is that size of tag will remain sizeof(int) irrespective of the number of constants in it.correct me if i am wrong !! Right. -- -- You received

Re: [algogeeks] C OUTPUT HELP

2011-07-12 Thread Kamakshii Aggarwal
for the second problem,y should the answer be 3 1?.it should be 3 2 and it is working fine on dev c++ giving 3 2. On Tue, Jul 12, 2011 at 2:48 PM, Anand Saha anands...@gmail.com wrote: On Tue, Jul 12, 2011 at 2:36 PM, nicks crazy.logic.k...@gmail.com wrote: and in problem 3 what i

Re: [algogeeks] C OUTPUT HELP

2011-07-12 Thread nicks
3 1 is the output which i predicted without running...it is giving 3 3 on gcc and may give 3 2 on dev c++ . output will be compiler dependent as these types of situations are not defined in standards hence implementation dependent..i want someone to explain the output with reference to

[algogeeks] C OUTPUT HELP

2011-07-11 Thread nicks
Guys plz help me in understanding the following output *PROBLEM 1.* * * #includestdio.h main() { int scanf=78; //int printf=45; int getchar=6; printf(%d,scanf); printf(\n%d,getchar); } *OUTPUT-* 78 6 in this problem my problem is using printf and scanf as variable names.they are functions

Re: [algogeeks] C OUTPUT HELP

2011-07-11 Thread nicks
@sandeep u mean whenever printf will demand for %f then it will print 2.0.is it random behavior or always going to happen ?? anyone else having better idea regarding 1st and 2nd problem... On Mon, Jul 11, 2011 at 9:51 AM, Sandeep Jain sandeep6...@gmail.com wrote: TurboC has many flaws, one

Re: [algogeeks] C OUTPUT HELP

2011-07-11 Thread varun pahwa
problem 3. I think tag is a reference so its size is 4 bytes. On Tue, Jul 12, 2011 at 1:29 AM, nicks crazy.logic.k...@gmail.com wrote: Guys plz help me in understanding the following output *PROBLEM 1.* * * #includestdio.h main() { int scanf=78; //int printf=45; int getchar=6;

Re: [algogeeks] C OUTPUT HELP

2011-07-11 Thread oppilas .
*OUTPUT-* 78 6 in this problem my problem is using printf and scanf as variable names.they are functions in the stdio.h then how are they available for variable name ??...generally what happens is that whenever we use some name for the function and then use that name for some variable

Re: [algogeeks] C OUTPUT HELP

2011-07-11 Thread Sandeep Jain
I'll put it in simple words, when printf is executed, it expects the arguments to be of the same type and in the same order as they appear in the format string. Otherwise, it starts to exhibit random behavior whenever a first mismatch occurs. Regards, Sandeep Jain On Tue, Jul 12, 2011 at 1:32

[algogeeks] C OUTPUT HELP

2011-07-10 Thread nicks
Someone please help me in understanding the following output - Problem *1.* #includestdio.h #ifdef getchar //this expression is evaluated to zero.why is so happening ??getchar is defined as macro in stdio.h.i mean else part shouldn't be executed which is happening #undef

Re: [algogeeks] C OUTPUT HELP

2011-07-10 Thread Sandeep Jain
*Problem 2:* I think u are using TurboC, since you have written void main() Secondly, printf (since based on macros) scans through the format string. And the it process arguments one by one depending on the format specifiers given in this string. I've observed that whenever there is a mismatch

Re: [algogeeks] C OUTPUT HELP

2011-07-10 Thread Kamakshii Aggarwal
for the first question...it will take #ifdef getchar to be '1' only when it is defined as a MACRO in your program..if u dont define macro it will not take it into consideration even if it is defined in header file. On Mon, Jul 11, 2011 at 12:38 AM, nicks crazy.logic.k...@gmail.com wrote:

Re: [algogeeks] C OUTPUT HELP

2011-07-10 Thread Kamakshii Aggarwal
probelm 5:It must be giving runtime error not segmentation fault coz it is an infinite recursion On Mon, Jul 11, 2011 at 1:09 AM, Kamakshii Aggarwal kamakshi...@gmail.comwrote: for the first question...it will take #ifdef getchar to be '1' only when it is defined as a MACRO in your

Re: [algogeeks] C OUTPUT HELP

2011-07-10 Thread nicks
@sandeep,kamakshiithanks both...your replies were really helpfuli understood my fault in 3,4,5...they are clea now..but i am still stuck with problem 1 and 2 @sandeepwhat if i am using turbo C...though i am using gcc on terminal in my linux system. moreover acc. t KR printf

Re: [algogeeks] C OUTPUT HELP

2011-07-10 Thread Sandeep Jain
TurboC has many flaws, one of the simplest examples would be char *p; scanf(%s, p); In gcc/g++ this will surely lead to segmentation fault as memory has not been allocated. Whereas in TC it will execute fine in most of the cases. Infact this will crash when your code is really large. As for

[algogeeks] c output:

2011-06-30 Thread hary rathor
program 1; output :1 int main() { int i; i= 1,2,3; printf(i:%d\n,i); return 0; } program 2; output: ERROR int main() { int i=1,2,3; printf(i:%d\n,i); return 0; } pls explain -- You received this message because you

Re: [algogeeks] c output:

2011-06-30 Thread aditya kumar
@harry: it ll b btr if u go to this link n clr ur doubts link : http://en.wikipedia.org/wiki/Comma_operator On Fri, Jul 1, 2011 at 3:56 AM, hary rathor harry.rat...@gmail.com wrote: program 1; output :1 int main() { int i; i= 1,2,3; printf(i:%d\n,i);

Re: [algogeeks] C OUTPUT HELP

2011-06-12 Thread Anika Jain
can anybody explain that in following code y output is coming to be: 7 6 8 void call(int a,int b,int c) { printf(%d %d %d,a,b,c); } int main() { int a=5; call(a++,a++,++a); return 0; } On Sat, Jun 11, 2011 at 8:21 PM, PRAMENDRA RATHi rathi prathi...@gmail.comwrote: IN second

Re: [algogeeks] C OUTPUT HELP

2011-06-12 Thread Anika Jain
thanks himanshu finally i got the reason!! :) On Sun, Jun 12, 2011 at 5:59 PM, himanshu kansal himanshukansal...@gmail.com wrote: @anika:cz on gcc arguemnts r eval frm right to left and assgnment to a pre increment expression is delayed vry mch so on eval frm right to left frst a is

Re: [algogeeks] C OUTPUT HELP

2011-06-12 Thread nicks
@himanshuwhat abt this ?? #includestdio.H # include conio.h int i=2; main() { void add(); add(i++,--i); printf(\ni=%d \n,i);system(pause); } void add(int a ,int b) { printf(\na=%d b=%d,a,b); } *OUTPUT -* a=1 b=1 i=2 acc. to ur logic output should be - a=1 b=2 i=2 On Sun, Jun 12,

Re: [algogeeks] C OUTPUT HELP

2011-06-12 Thread UMESH KUMAR
void call(int a,int b,int c) { printf(%d %d %d,a,b,c); } int main() { int a=5; call(a++,a++,++a); return 0; } On Sat, Jun 11, 2011 at 8:21 PM, PRAMENDRA RATHi rathi prathi...@gmail.com wrote: IN second program: in function value are always push in the stack from

Re: [algogeeks] C OUTPUT HELP

2011-06-12 Thread nicks
@umesh...thanks :) this explanation seems to be satisfactory but failed to understand from where @anika and @himanshu were getting 7 6 8i ran it...output comes out to be 7 6 6 !! On Sun, Jun 12, 2011 at 6:15 AM, UMESH KUMAR kumar.umesh...@gmail.comwrote: void call(int a,int b,int c) {

Re: [algogeeks] C OUTPUT HELP

2011-06-12 Thread sanjay ahuja
with GCC the above code gives a = 1 and b = 2 On Sun, Jun 12, 2011 at 6:39 PM, nicks crazy.logic.k...@gmail.com wrote: @himanshuwhat abt this ?? #includestdio.H # include conio.h int i=2; main() {  void add();  add(i++,--i);     printf(\ni=%d \n,i);system(pause); } void add(int a

Re: [algogeeks] C OUTPUT HELP

2011-06-12 Thread nicks
no it's a=1 b=1 i=2 i ran it on gcc (linux ubuntu 11.04) On Sun, Jun 12, 2011 at 6:26 AM, sanjay ahuja sanjayahuja.i...@gmail.comwrote: with GCC the above code gives a = 1 and b = 2 On Sun, Jun 12, 2011 at 6:39 PM, nicks crazy.logic.k...@gmail.com wrote: @himanshuwhat abt this ??

Re: [algogeeks] C OUTPUT HELP

2011-06-12 Thread nicks
but program by anika is giving *7 6 8* on gcc.but *7 6 6 *on dev-cpp...i am wondering if the output is compiler dependent !! On Sun, Jun 12, 2011 at 6:33 AM, nicks crazy.logic.k...@gmail.com wrote: no it's a=1 b=1 i=2 i ran it on gcc (linux ubuntu 11.04) On Sun, Jun 12, 2011

[algogeeks] C OUTPUT HELP

2011-06-11 Thread nicks
Hello friends..plz help me in understanding the following C Output first one is -- #includestdio.h #includeconio.h main() { int a=5; printf(a=%d\n,a); printf(%a=%d,a); getch(); } *OUTPUT - * a=5 0x1.2ff380p-1021=4199082 and the other one is -- #includestdio.H # include conio.h int i=2; main()

Re: [algogeeks] C OUTPUT HELP

2011-06-11 Thread Vishal Thanki
In 1st program, 2nd printf requires one more argument. And basically %a is used for printing a double value in hex. see man 3 printf. On Sat, Jun 11, 2011 at 5:29 PM, nicks crazy.logic.k...@gmail.com wrote: Hello friends..plz help me in understanding the following C Output first one is --

Re: [algogeeks] C OUTPUT HELP

2011-06-11 Thread PRAMENDRA RATHi rathi
IN second program: in function value are always push in the stack from left. so first value is --i that will make i=1 and pass to function and after that i++ will be passed.that's means i will be passed and after that value will be incremented. so 1 will pass and after passing value. i will

Re: [algogeeks] C OUTPUT HELP

2011-06-11 Thread PRAMENDRA RATHi rathi
IN second program: in function value are always push in the stack from right. so first value is --i that will make i=1 and value 1 will be passed to function and after that i++ that's means i will be passed. so 1 will be passed and after passing value. i will changed to 2. if u want to know why

Re: [algogeeks] c++ output

2011-06-08 Thread hary rathor
because compiler have know about g funtion while evaluating f -- 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

2011-06-07 Thread sourabh jakhar
int main() { g(); f(); } inline int f(){ g(); return g()+1; } inline int g() { return 1; } this code works but if removed inline than gives run time error can any one explain -- SOURABH JAKHAR,(CSE)(3 year) ROOM NO 167 , TILAK,HOSTEL 'MNNIT ALLAHABAD The Law of Win says, Let's not do it your

Re: [algogeeks] c++ output

2011-06-07 Thread nicks
Check this is working fine.. int g() { return 1; } int f(){ g(); return g()+1; } int main() { g(); f(); } On Tue, Jun 7, 2011 at 12:29 PM, sourabh jakhar sourabhjak...@gmail.comwrote: int main() { g(); f(); } inline int f(){ g(); return g()+1; } inline int g() { return 1; }

Re: [algogeeks] c++ output

2011-06-07 Thread bhavana
Because in C++ we need to declare the function before using it. With keyword inline...the complete code of the function is replaced wherever it is called. I hope now its clear why the above code is not working. On Wed, Jun 8, 2011 at 9:32 AM, nicks crazy.logic.k...@gmail.com wrote: Check this

[algogeeks] c output

2011-06-01 Thread himanshu kansal
a=++b*++b; if b=3 initially, then a is coming out to be 25.why -- 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-06-01 Thread Vishal Thanki
you may want to read: http://c-faq.com/expr/seqpoints.html On Wed, Jun 1, 2011 at 5:19 PM, himanshu kansal himanshukansal...@gmail.com wrote: a=++b*++b; if b=3 initially, then a is coming out to be 25.why -- You received this message because you are subscribed to the Google Groups

Re: [algogeeks] c output

2011-06-01 Thread anuj agarwal
This will be same as: b=b+1; b=b+1; a=b*b; Basically, all prefix increment and decrement operators will be executed first. Similarly all postfix operators will be executed at last. Anuj Agarwal Engineering is the art of making what you want from things you can get. On Wed, Jun 1, 2011 at 5:27

[algogeeks] C Output

2011-05-29 Thread Ankit Agarwal
#includestdio.h int main(void) { float a=0.08; if(a0.08) printf(Hello\n); else printf(Hii\n); return 0; } The o/p is: *Hello * why -- Ankit Agarwal -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To

Re: [algogeeks] C Output

2011-05-29 Thread Vishal Thanki
a 0.08f will make it compare to float. by default 0.08 is considered as double. On Sun, May 29, 2011 at 9:51 PM, Ankit Agarwal ankitgeniu...@gmail.com wrote: #includestdio.h int main(void) {     float a=0.08;     if(a0.08)         printf(Hello\n);     else         printf(Hii\n);    

Re: [algogeeks] C Output

2011-05-29 Thread sravanreddy001
and, I read it long time back that.. the value of 0.8 alone will be stored as 0.7995 (not sure on the number of 9's but.. the last digit in the precision will be a 5) that could be a reason. may be what vishal said is correct. -- You received this message because you are subscribed to

Re: [algogeeks] C Output

2011-05-29 Thread Vishal Thanki
you may want to check how the floats and doubles are stored into memory using ieee notation. i tried to print 0.08 and 0.08f in hex format and got the following result. vishal@ubuntu:~/progs/c\ 10:03:56 AM $ cat fl.c #include stdio.h int main() { float f=0.08; if (f 0.08f)

Re: [algogeeks] C Output

2011-05-29 Thread arjoo kumar
when u store 0.08 on the float variable a then it does not store exactly 0.08 on 'a' actually it store 0.7999 that's why after comparition it make less quantity with 0.08 i.e 'if ' condition is true and print it HELLO On Sun, May 29, 2011 at 9:21 AM, Ankit Agarwal

Re: [algogeeks] C Output

2011-05-29 Thread Ankit Agarwal
Thank u guys :) :) On Mon, May 30, 2011 at 10:40 AM, arjoo kumar 2009ar...@gmail.com wrote: when u store 0.08 on the float variable a then it does not store exactly 0.08 on 'a' actually it store 0.7999 that's why after comparition it make less quantity with 0.08 i.e 'if ' condition is

[algogeeks] c output

2011-05-25 Thread sourabh jakhar
#includestdio.h #includestdio.h #includeconio.h #define PRINTX printf(%d\n,x) main() { int x=2,y,z; x*=3 + 2; PRINTX; x*= y = z = 4; PRINTX; x = y == z; PRINTX; x == ( y = z ); PRINTX; getch(); } can anyone explain the output -- SOURABH JAKHAR,(CSE)(3 year) The Law of Win

Re: [algogeeks] c output

2011-05-25 Thread Naveen Kumar
output is 10 40 1 1 10 because x = x*(3+2) = 2 * (3+2) 40 because x = x*4 = 10 * 4 1 because x = y == z which is x = 4 == 4 which become x = 1 1 becase value of x is not changed in 4th expression. On Wed, May 25, 2011 at 3:35 PM, sourabh jakhar sourabhjak...@gmail.comwrote: #includestdio.h

Re: [algogeeks] c output

2011-05-25 Thread Shachindra A C
1st print : x = x * (3 + 2) - 10 2nd print : x = x * 4 - 40 : while evaluating the expression, the rightmost result will be used 3rd print : x = (4 == 4) - 1 4th print : x == ( y = z ) evaluates to false; prev val of x, 1 is printed On Wed, May 25, 2011 at 3:35 PM, sourabh jakhar

Re: [algogeeks] c output

2011-05-25 Thread sourabh jakhar
ok i got it is the precedence of *= is less than of + On Wed, May 25, 2011 at 3:52 PM, Shachindra A C sachindr...@gmail.comwrote: 1st print : x = x * (3 + 2) - 10 2nd print : x = x * 4 - 40 : while evaluating the expression, the rightmost result will be used 3rd print : x = (4 == 4) - 1

[algogeeks] C OUTPUT

2011-05-22 Thread sourabh jakhar
#includestdio.h void main() { long x; float t; scanf(%f,t); printf(%d\n,t); x=90; printf(%f\n,x); { x=1; printf(%f\n,x); { x=30; printf(%f\n,x); } printf(%f\n,x); } x==9; printf(%f\n,x);

Re: [algogeeks] C output... ???

2010-12-16 Thread UMESH KUMAR
#define SIZE 10 int main() { int arr[SIZE]; printf(size of array is:%d\n,sizeof(arr)); return 0; } when we call the function and pass the name of the ARRAY ,then PUSH the base Address of the ARRAY in the Stack of the Calling Function not PUSH the

Re: [algogeeks] C output... ???

2010-12-15 Thread Tagged
Is it that the first case its a pointer to a pointer. So size of pointer to a pointer is 4. In next case , Its the size of array. So its 40. Is the explanation correct? On Wed, Dec 15, 2010 at 9:43 AM, rahul rahulr...@gmail.com wrote: you would like to read peter ven der linden.(deep C

[algogeeks] C output... ???

2010-12-14 Thread Divesh Dixit
#define SIZE 10 void size(int arr[SIZE]) { printf(size of array is:%d\n,sizeof(arr)); } int main() { int arr[SIZE]; size(arr); return 0; } the out put should be 40 considering 4 byte integer... but out put is only 4... how this is possible...

Re: [algogeeks] C output... ???

2010-12-14 Thread Manmeet Singh
When you pass an array as argument, it gets broken into a pointer. So you get size as 4 for 32 bit machine. On Tue, Dec 14, 2010 at 10:59 PM, Divesh Dixit dixit.coolfrog.div...@gmail.com wrote: #define SIZE 10 void size(int arr[SIZE]) { printf(size of array is:%d\n,sizeof(arr));

Re: [algogeeks] C output... ???

2010-12-14 Thread Saurabh Koar
When u r passing an array to a function u only pass the base address nt the total array...bt when sizeof is applied in main() u hv the whole array. Thats why in the first case the output is 4(only one address that is capable of holdin one integer)bt in the 2nd case the output is 40(as u hv 10

Re: [algogeeks] C output... ???

2010-12-14 Thread rahul
you would like to read peter ven der linden.(deep C secrets). On Tue, Dec 14, 2010 at 11:19 PM, Saurabh Koar saurabhkoar...@gmail.comwrote: When u r passing an array to a function u only pass the base address nt the total array...bt when sizeof is applied in main() u hv the whole array. Thats

Re: [algogeeks] c output

2010-06-11 Thread mohit ranjan
@Divya o/p c prints b 1 - prints a 6, 2 --- printf returns no of characters printed. 6=5 (length of a) + 1 (for \n) 2=1 (length of b) + 1 (for \n) Hope it's

Re: [algogeeks] c output

2010-06-11 Thread Anurag Sharma
printf returns number of successfully printed characters. so printf(1\n) will return 6 and printf(c\n) will return 2 due to the extra '\n' character which is also being printed I hope the output is now clear Anurag Sharma On Fri, Jun 11, 2010 at 12:26 AM, divya sweetdivya@gmail.com

Re: [algogeeks] c output

2010-06-11 Thread chetan thorat
The return value of printf is the number of characters it prints successfully. So the rightmost printf is going to return 2 (one for char c and one for new line), similarly second one returning 6. Regards, Chetan. On 11 June 2010 00:56, divya sweetdivya@gmail.com wrote: #include stdio.h

Re: [algogeeks] c output

2010-06-11 Thread Raj N
It will be c 1 6 2 6 and 2 because of newline On Fri, Jun 11, 2010 at 9:26 AM, Rohit Saraf rohit.kumar.sa...@gmail.comwrote: c 1 6,2 u might be expecting 5,1 if u are forgetting the newline character :) -- Rohit Saraf Second Year

Re: [algogeeks] c output

2010-06-11 Thread Ashish kumar Jain
Explanation: The prototype for printf as per ANSI C is: *int printf( const char *format,…)* the return value is integer and returns the number of characters successfully read by printf. Also,in case of printf(),the evaluation of expressions passed on as arguments is done from right to

[algogeeks] c output

2010-06-10 Thread divya
#include stdio.h main() { int a = 1; char b='c'; int i,j; printf(%d,%d,printf(%d\n,a),printf(%c\n,b)); wat shd b the o/p of this..plzz explain y? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

Re: [algogeeks] c output

2010-06-10 Thread Rohit Saraf
c 1 6,2 u might be expecting 5,1 if u are forgetting the newline character :) -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 -- You received this message

<    1   2   3