Thread: a basic one

  1. #1
    Registered User
    Join Date
    Feb 2005
    Posts
    17

    a basic one

    i have a very basic question.
    following is the code
    Code:
    # include<stdio.h>
    # include<conio.h>
    void main()
    {
    int i=012;
    int j=024;
    int k=036;
    
    printf("%d  %d  %d ",i,j,k);
    getch();
    }
    
    >
    the output is 10,20,30..........
    why is it not 12,24,36?

  2. #2
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    012 is not 12 decimal its 12 octal. the 0 means treat this as octal similarly as 0x means treat this as hex. same for 024 and 036. All octal numbers(base 8)
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  3. #3
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    You're lucky it works at all. It doesn't have to you know, because main is not a void function. That's undefined.

    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. [ANN] New script engine (Basic sintax)
    By MKTMK in forum C++ Programming
    Replies: 1
    Last Post: 11-01-2005, 10:28 AM
  2. what are your thoughts on visual basic?
    By orion- in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 09-22-2005, 04:28 AM
  3. visual basic vs C or C++
    By FOOTOO in forum Windows Programming
    Replies: 5
    Last Post: 02-06-2005, 08:41 PM
  4. Basic Window Creation, Dev C++ 4.9.9.0 Linking Error
    By Tronic in forum Windows Programming
    Replies: 2
    Last Post: 11-27-2004, 06:03 PM