Skip to main content

Hexadecimal and Octal Constant in C Programming



Octal:  The number system based on 8 is called octal and uses the digits 0 through 7. In octal, the number 15 is the same as 13 in decimal.
Hexadecimal: The base 16 number system is called hexadecimal and uses the digits 0 through 9 plus the letters A through F, which stand for 10, 11, 12, 13, 14, and 15, respectively. For example, the hexadecimal number A is 10 in decimal.
It is sometimes more easier to use a number system based on 8 or 16 rather than 10. Because these two number systems are used frequently, C allows usto specify integer constants in hexadecimal or octal instead of decimal. A hexadecimal constant must consist of a Ox followed by the constant in hexadecimal form. An octal constant begins with a 0.


Here are two examples:
int hex = 0x40;      in Decimal 64
int oct = 040;         in Decimal 32

Comments

  1. APTRON Solutions with its start-of-workmanship class rooms and Lab infrastructure at Delhi offer the best and most conducive learning environment, with a team of highly skilled trainers having years of industry experience.
    For More Info: Java Training in Delhi

    ReplyDelete

Post a Comment

Give your valuable Comment...

Popular posts from this blog

Object-Oriented Programming and JAVA Programming Language

  Object-Oriented Programming and:   Object-oriented programming (OOP) is a programming paradigm using "objects" – data structures consisting of data fields and methods together with their interactions – to design applications and computer programs. Programming techniques may include features such as data abstraction, encapsulation, messaging, modularity, olymorphism, and inheritance. Many modern programming languages now support OOP, at least as an option. JAVA Programming Language: Object-oriented programming is at the core of Java. In fact, all Java programs are object-oriented, this isn’t an option the way that it is in C++, for example. OOP is so integral to Java that you must understand its basic principles before you can write even simple Java programs. Therefore, this chapter begins with a discussion of the theoretical aspects of OOP.

Read or input form user in Java using BufferedReader

 BufferedReader use to read text from a character-input stream, buffering characters so as to provide for the efficient reading of characters, arrays, and lines.The buffer size may be specified, or the default size may be used. The default is large enough for most purposes. In Java  BufferedReader is a efficient method to read an input. Here given a short example to read a string from user and print it: package palindrome; import java.io.BufferedReader; import java.io.InputStreamReader; public class  inputExample   {     public static void main(String[] args) throws Exception {    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));     String s = new String();       s =br.readLine();     System.out.println(s);     } }

Difference between Scanner vs. BufferedReader

BufferedReader Read text from a character-input stream, buffering characters so as to provide for the efficient reading of characters, arrays, and lines. The buffer size may be specified, or the default size may be used. The default is large enough for most purposes. Where Scanner is a simple text scanner which can parse primitive types and strings using regular expressions. A Scanner breaks its input into tokens using a delimiter pattern, which by default matches whitespace. The resulting tokens may then be converted into values of different types using the various next methods. Scanner is used for parsing tokens from the contents of the stream while BufferedReader just reads the stream and does not do any special parsing. In currently latest JDK6 release/build, the Scanner has a littler buffer (1KB char buffer) as opposed to the BufferedReader (8KB byte buffer), but it's more than enough.As to the choice, use the Scanner if you want to parse the file, use the Buffered