LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 01-30-2012, 12:08 PM   #1
mscoder
LQ Newbie
 
Registered: Jun 2011
Posts: 9

Rep: Reputation: Disabled
binary variable in c programme..


Code:
int main()
  
{
    int binary,binary2;
    binary1 =0100;
    binary2=0110;
    printf("%d\t%d\n",binary1,binary2);//prints 64 72..why?
    return(0);                                        
                                                                                            
}
why is the number treated as binary?? is any variable consisting of only zeroes and ones treated as binary??

Last edited by mscoder; 01-30-2012 at 12:11 PM.
 
Old 01-30-2012, 12:14 PM   #2
NevemTeve
Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 269

Rep: Reputation: 90
Octal, actually: numbers beginning with '0' are octal: 0100 = 8^2, 0110 = 8^2+8^1
 
1 members found this post helpful.
  


Reply

Tags
printf


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
command for identifying the environment variable in a binary at the compilation time logeswari.r Linux - Newbie 8 06-15-2011 07:13 PM
Linux utility to combine two or more binary files into a single binary file mageshvan Programming 7 05-05-2011 08:06 AM
Storing multiple options in a single variable (binary addition?) matt_heys Programming 1 04-03-2009 03:38 PM
XOR Binary Stream Against a Known Binary Key telecom_is_me Programming 14 07-04-2008 07:10 PM
Do I need binary 1 and binary 2 dvd iso for base install? salah-ad-din Debian 5 08-15-2006 04:43 PM


All times are GMT -5. The time now is 11:20 AM.

Main Menu
 
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration