Re: Post ur C/C++ Programs Here
Hey guys,,
come on i've got something to ask u all??
1. What will be the output of:
int main()
{ int a=5;
printf("%d",printf("%f",a));
}
output wil be garbage but you would hav asked for reason instead of the output
the outputs which i got were
-0.899265
9
-0.019636
9
-0.034090
9
and you can see number 9 at the end of each output an that is the output of printf("%d", and the rest out put is of printf("%f",a) acttualy if you use \n in 2nd printf
like
printf("%d",printf("%f\n",a));
you should be able to see output somthing like
-0.039340 printf("%f\n",a)
10 printf("%d"
since you are printing an integer value in float format internal conversion will make output something like -0.019636 (garbage) and then second printf will print the return value of first printf ie number of characters it printed ie in above case it is 9 characters hence output will be -0.019636
9
2. What are command line arguments? How to use them??
I know a bit abt it. If someone knows it better plz share here...
It is the way of passing arguments to main function ..
main(int argc, char *argv[])
so you can pass arguments to this main function at command promt
promt$ ./program hello 3 name
argv[0] argv[1] argv[2] argv[3]
so main will get 4 arguments as above .. and argc will be 4
3. How is VAriable Argument list used.. Plz explain with a good xample.
you mean to say variable argument in functions ???