Q:
Swift program to create a constant with hexadecimal value and print it in decimal number
belongs to collection: Swift Basic Programs
Swift Basic Programs
- Swift program to print \'Hello World\'
- Swift program to create different types of variables
- Swift program to create variables with specifying data type
- Swift program to demonstrate the escape sequences
- Swift program to demonstrate the \'\\()\' to embed the value of the variable within the string
- Swift program to create a constant
- Swift program to create a constant with binary value and print it in decimal number
- Swift program to create a constant with hexadecimal value and print it in decimal number
- Swift program to create an alias of basic types
- Swift program to print the line number of source code using the #line directive
- Swift program to print the size of variables
- Swift program to read an integer number from the user
- Swift program to read a float number from the user
- Swift program to demonstrate the Int() function with Invalid value
- Swift program to print the character corresponding ASCII value
- Swift program to demonstrate the arithmetic operators
- Swift program to demonstrate the assignment operators
- Swift program to assign multiple variables in a single statement
- Swift program to demonstrate the unary minus \'-\' and unary plus \'+\' operators
- Swift program to demonstrate the comparison operators
- Swift program to demonstrate the logical AND (&&) operator
- Swift program to demonstrate the logical OR (||) operator
- Swift program to demonstrate the logical NOT (!) operator
- Swift program to demonstrate the closed range operator
- Swift program to demonstrate the Half-Open range operator
- Swift program to demonstrate the one-sided range operator
- Swift program to perform the bitwise left-shift operation
- Swift program to perform the bitwise right-shift operation
- Swift program to perform the bitwise AND operation
- Swift program to perform the bitwise OR operation
- Swift program to perform the bitwise XOR operation
- Swift program to perform the bitwise NOT operation
- Swift program to swap two numbers using the bitwise XOR operator
- Swift program to print the minimum and maximum value of data type Int8
- Swift program to print the minimum and maximum value of data type UInt8
- Swift program to print the minimum and maximum value of data type Int
Program/Source Code:
The source code to create a constant with hexadecimal value and print it in a decimal number is given below. The given program is compiled and executed successfully.
Output:
Explanation:
Here, we created a constant num using the let keyword initialized with hexadecimal number 0x30. Then we printed the corresponding decimal number on the console screen.
need an explanation for this answer? contact us directly to get an explanation for this answer