Like Tree7Likes
  • 3 Post By cas
  • 1 Post By memcpy
  • 1 Post By Salem
  • 2 Post By cas

Basic C programming 3

This is a discussion on Basic C programming 3 within the C Programming forums, part of the General Programming Boards category; #include<stdio.h> #include<math.h> int main(x) { int y,z; y=-~x; z=printf("hi\r"); printf("%d",x = pow(z,y)); } output :- 9i Please explain how 'x' ...

  1. #1
    Registered User
    Join Date
    Jun 2012
    Posts
    21

    Basic C programming 3

    #include<stdio.h>

    #include<math.h>
    int main(x)
    {
    int y,z;


    y=-~x;
    z=printf("hi\r");
    printf("%d",x = pow(z,y));

    }


    output :- 9i

    Please explain how 'x' is taking some int value
    Last edited by vivekgupta; 06-12-2012 at 04:51 PM.

  2. #2
    cas
    cas is offline
    Registered User
    Join Date
    Sep 2007
    Posts
    983
    Please use code tags.

    Where are you getting this horrible code? main() is declared incorrectly, but what's probably happening is that “x” is being passed the argument count (what is traditionally called argc). Since this is a pre-ANSI declaration, and no type is given for “x”, it defaults to int, which is why it'd be taking "some int value".

    I highly recommend that, if you're actually interested in learning C, you stop going to whatever site/reading whatever book is giving you this junk. It's worthless.
    stahta01, laserlight and Salem like this.

  3. #3
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,712
    Quote Originally Posted by cas
    I highly recommend that, if you're actually interested in learning C, you stop going to whatever site/reading whatever book is giving you this junk. It's worthless.
    Yes, please. You've already been told this before. Persisting in learning rubbish is futile. (Okay, it is not completely rubbish, but the trivia that this involves just hinders your useful learning.)
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  4. #4
    Registered User
    Join Date
    Dec 2011
    Posts
    795
    Can't tell if crossposter, or just copied from here. FFS, you need to learn the basics of C before you even touch bitwise operations.

    Also, why are all of your topics pretty much:
    *some ........ed-up code*

    output :- *some undefined error*

    Please explain *something obvious*
    stahta01 likes this.

  5. #5
    Registered User
    Join Date
    Jun 2012
    Posts
    21
    So please say which book should i read to learn C from 'very basic' to a better and better level ?? And Should I learn C++ because my friend told me to learn C++ direct
    Last edited by vivekgupta; 06-13-2012 at 03:35 AM.

  6. #6
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,532
    Here's a list of things to watch out for when choosing a book. If you see any of these, put it down and find another book.
    The title contains adjectives like "guru" or "dummies"
    The title mentions a specific compiler like "TurboC"
    The title mentions a timescale like "21 days" (see Teach Yourself Programming in Ten Years)

    Skim the code examples in the book. If you see any of these, put it down and walk away.
    void main()
    gets(buffer), unless it is a single example telling you NOT to use it (which would be a positive sign)
    fflush(stdin)

    The author is "herbert schildt", Showing 1 - 12 of 154 Results
    For those who can't do maths, that's one new book or edition every 3 weeks for a solid decade!
    "written by" should be read as "cobbled together by an army of ghost writers, then rubber stamped by HS"
    bullschildt

    This site has a number of reviews
    ACCU :: Book Reviews Search
    rags_to_riches likes this.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  7. #7
    cas
    cas is offline
    Registered User
    Join Date
    Sep 2007
    Posts
    983
    So please say which book should i read to learn C from 'very basic' to a better and better level ??
    In addition to what Salem said, I will specifically recommend against Let Us C by Yashavant Kanetkar; this book is ridiculously bad. I mention it only because it is a popular book in India and your username implies that you might be Indian.

    As for C++, you should learn it if you want to learn it.

  8. #8
    Registered User manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    Kolkata@India
    Posts
    2,498
    Quote Originally Posted by cas View Post
    In addition to what Salem said, I will specifically recommend against Let Us C by Yashavant Kanetkar; this book is ridiculously bad. I mention it only because it is a popular book in India and your username implies that you might be Indian.
    ....that's putting it lightly.
    It proudly portrays every sort of code that should be specifically warned against.

    (I saw a recent version with a chapter on Linux Programming, though ...which wasn't written so badly.)
    Manasij Mukherjee | gcc-4.8.2 @Arch Linux
    Slow and Steady wins the race... if and only if :
    1.None of the other participants are fast and steady.
    2.The fast and unsteady suddenly falls asleep while running !



  9. #9
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,650
    How did YK get Turbo C to run on Linux???

  10. #10
    Registered User manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    Kolkata@India
    Posts
    2,498
    Quote Originally Posted by rags_to_riches View Post
    How did YK get Turbo C to run on Linux???
    ... the code in that chapter is 'standard' code and has a quite different style than the rest of the book.
    (Could be written by someone else..)
    Manasij Mukherjee | gcc-4.8.2 @Arch Linux
    Slow and Steady wins the race... if and only if :
    1.None of the other participants are fast and steady.
    2.The fast and unsteady suddenly falls asleep while running !



  11. #11
    Registered User R41D3N's Avatar
    Join Date
    Mar 2012
    Location
    ...Beyond Infinity, Behind a KeyBoard...
    Posts
    29
    lol Let Us C by YK can be used as a book to refer to so as to know how not to code :P ...

    For C++, you dont need to start out with C. If your final aim is C++, better you start of directly with it than going about in circles ...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Basic C programming -1
    By vivekgupta in forum C Programming
    Replies: 29
    Last Post: 06-11-2012, 03:26 PM
  2. Basic C programming help
    By jonny0503 in forum C Programming
    Replies: 3
    Last Post: 01-13-2012, 12:00 PM
  3. Basic c programming help
    By benrogers in forum C Programming
    Replies: 12
    Last Post: 01-24-2011, 04:01 PM
  4. basic C programming help
    By helfone in forum C Programming
    Replies: 3
    Last Post: 10-22-2007, 09:54 AM
  5. Basic Programming
    By plexy1 in forum C Programming
    Replies: 2
    Last Post: 09-05-2001, 02:03 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21