Posts

Showing posts from November, 2020

Endianness

Image
Endianness: Programmers who work on high level languages they don’t think about the hardware endianness or computer architectures; they only think about the code and the executable part and not how to convert little endian to big endian or vice versa. But we should know how to deal with endianness; as sometimes it plays an important role and can create problem when transmitting from one computer and receiving on another whose endianness differ. When communicating between computers, if the endianness differs of that two(computers), the data transmitted can’t be received in the actual form. What is Endianness? Endianness refers to the byte order in which data is stored in the memory; also describes the byte order sent over a digital link. The term may also be used more generally for the internal ordering of any representation . The endianness is categorized into two types: Little endianness Big endianness Note : It is hardware dependent. Little Endianness: In this...

Data Types in C

Image
 Introduction: There are two types of data: constants and variables. Constants is the data that cannot be changed once assigned; Variables data type is the data which can e changed whenever required. Data is of four types: int real char string Syntax for declaring variable: Note: When we declare variable, memory will be allocated to the variable but it contains “garbage value” (in case of auto variable) Default variables are signed. If we declare it as well as initialize it, it is known as “Initialization”             Example:               int a =Declaration               int a=10; = Initialization  Rules for constructing integer constants: Integer constant must contain one digit It must not have a decimal digit or value It can be positive or negative; if no sign mentioned default considered as positive. No commas and blanks are allowed in betw...

Errors in C Language

Image
Errors are categorized  into two type: Warnings Errors 1. Warnings: Warnings, which indicate a potential problem, but still let your code compile. Warnings are sort of future bugs that will appear at runtime i.e. We might get undesired output even the inputs and the code are properly crafted. The modern compilers mostly generate the warnings and still compile your code till the executable file; the modern compilers automatically detect the problems and solve it on its own if it is small. Example: In this example below, we haven’t included the string library and still using string based predefined function in the program; the program will execute in this case but warning will come as “include <string.h> or provide a declaration for strlen ()”   To avoid warning:  You must include proper header files in the program. In above case, include string-based functions header file i.e. Write #include<string.h> before main (). 2. Errors: Types of er...