*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 between the argument passed
& the format specifier, all subsequent values printed exhibit undefined
behavior.

*Problem 3:*
String literals are equivalent to char*.
Now when you write something like "hello"+1, it is treated as a
string beginning from the second character i.e. "ello"
So in your case
"\nACM-CIC"+3 ==> "M-CIC"
and 4+"\nACM-CIC" ==> "\nACM-CIC"+4 ==> "-CIC"
It has nothing to do with format string, rather char* (string literals
themselves)

*Problem 4:*
you are not assigning anything to i


Regards,
Sandeep Jain



On Mon, Jul 11, 2011 at 12:38 AM, nicks <[email protected]> wrote:

> Someone please help me in understanding the following output -
>
> Problem *1>.*
> #include<stdio.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 getchar
> #else
> #define getchar scanf("%c",&ch);
> #endif
> main()
> {
> char ch;
>  int c;
> c=getchar;
> printf("%d",c);
> }
>
> *OUTPUT-  1*
> *
> *
> *
> *
> *2>.*
> #include<stdio.h>
> void main()
> {
> long x;
>  float t;
> scanf("%f",&t);
> printf("%d\n",t);
>  x=90;
> printf("%ld\n",x);
> {
>  x=1;
> printf("%f\n",x);
> {
>  x=30;
> printf("%f\n",x);
> }
>  printf("%f\n",x);
> }
> x==9;
>  printf("%f\n",x);
> }
>
> *OUTPUT(INPUT IS 2) -*
> *2*
> *0*
> *90*
> *2.000000*
> *2.000000*
> *2.000000*
> *2.000000*
> *
> *
> In this problem i failed to Understand why t is printed as 0 (though float
> is converted to integer by truncation of the fractional part)
> and how the value of t is transferred to x....looks very strange to me !!
>
>
> *3>.*
> #include<stdio.h>
> main()
> {
>     printf("\nACM-CIC"+3);
>     printf(4+"\nACM-CIC");
>
> }
>
> *OUTPUT -*
> *M-CIC-CIC*
> *
> *
> What does +3 and +4 doing and does it matter to use them before the format
> string or after it ??
>
> *4>.*
> #include<stdio.h>
> main()
> {
> long long i=50;
> i==1000000000000000000000000000000000000000;
>  printf("i=%d\n\n%lld",sizeof(i),i);
> //system("pause");
> }
>
> *OUTPUT -*
> *i=8*
> *
> *
> *50*
> *
> *
> Assigning very large value to i isn't changing it's value.....why is so
> happening ??
>
> and the last one
>
> *5>.*
> #include<stdio.h>
> main()
> {
> static int i=0;
>  if(i<=-1)
> printf("\nBull's Eye");
> else
>  {
> main();
> _exit(1);
>  }
> i++;
> }
>
> *OUTPUT -*
> *segementation fault*
> *
> *
> What's Wrong with the above Code due to which it is giving Runtime
> error....plz help me pointing it out !!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> 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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to