Results 1 to 5 of 5

Thread: BUYS: C Concept Share/Save - My123World.Com!

  1. #1

    BUYS: C Concept

    Learned the importance of something today, so sharing it here....


    #include <stdio.h>
    #include <stdlib.h>
    int main()
    {
    func(3.0);
    return 0;
    }

    double func(double x)
    {
    return x;
    }
    Question is : what will be the output ?? And Reason too ??
    JAI MATA DI

    *

    Silence is not our weakness, Its just we dont want to waste our time...........

  2. #2
    Super Commando Dhruv abhaythehero's Avatar
    Join Date
    Sep 2010
    Location
    Lucknow/Pune,India
    Posts
    466
    Blog Entries
    2
    @s1ayer

    PM sent. Do check it
    In the world of 0s and 1s, are you a zero or The One !

  3. #3
    Network Security Administrator Hackuin's Avatar
    Join Date
    Apr 2011
    Location
    10011001 10011001
    Posts
    104
    At the first glance itself, it is known that it will not compile.

    Reason:
    Compiler must know the function's return type, the number of parameters it uses, and the type of each parameter, before the function is called.

    Workaround:
    Either define the function func() first. [ That is, place the function func() before the main() function ] or
    Define the function prototype. [ That is, double func(double); ]
    "Free software" is a matter of liberty, not price. To understand the concept, you should think of "free" as in "free speech," not as in "free beer."
    "Microsoft is not the answer. Microsoft is the question. NO (or Linux) is the answer."
    "Ubuntu - Linux For Human Beings."

    Currently reading books:
    Integrating Forensic Investigation Methodology into eDiscovery -- by Colin Chisholm.
    Digital Forensics with Open Source Toolss -- by Cory Altheide && Harlan Carvey.

  4. #4
    Super Commando Dhruv abhaythehero's Avatar
    Join Date
    Sep 2010
    Location
    Lucknow/Pune,India
    Posts
    466
    Blog Entries
    2
    @Hackuin

    Nice that you answered , but we generally send answers by PM for some initial time and it is the responsibility of the person who asked the question to post all the answers back when the time is over. This lets a wide range of members attempt the question who may come online once in 2-3 days. Full guidelines here http://www.garage4hackers.com/f49/br...sting-836.html
    In the world of 0s and 1s, are you a zero or The One !

  5. #5
    Was that the only trap? Isn't that quite logical in almost all languages that function definition shall come first before a call is made to that function so that compiler is aware of it? Or the thread starter is looking for something else?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •