- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 1452 Articles for C
18K+ Views
The sizeof operator is the most common operator in C. It is a compile-time unary operator and used to compute the size of its operand. It returns the size of a variable. It can be applied to any data type, float type, pointer type variables.When sizeof() is used with the data types, it simply returns the amount of memory allocated to that data type. The output can be different on different machines like a 32-bit system can show different output while a 64-bit system can show different of same data types.Here is an example in C language, Example Live Demo#include ... Read More
4K+ Views
Typecasting is a method in C language of converting one data type to another.There are two types of typecasting.1.Implicit Type casting − This conversion is done by the compiler. When more than one data type of variables are used in an expression, the compiler converts data types to avoid loss of data.Here is an example of implicit type casting in C language, Example Live Demo#include int main() { int a = 10; char b = 'S'; float c = 2.88; a = a+b; printf("Implicit conversion from character to integer : %d", a); c = ... Read More
13K+ Views
Variables in C are associated with data type. Each data type requires an amount of memory and performs specific operations.There are some common data types in C −int − Used to store an integer value.char − Used to store a single character.float − Used to store decimal numbers with single precision.double − Used to store decimal numbers with double precision.The following table displays data types in C language −Data TypesBytesRangeshort int2-32, 768 to 32, 767unsigned short int20 to 65, 535unsigned int40 to 4, 294, 967, 295int4-2, 147, 483, 648 to 2, 147, 483, 647long int4-2, 147, 483, 648 to 2, ... Read More
15K+ Views
Tokens are the smallest elements of a program, which are meaningful to the compiler.The following are the types of tokens: Keywords, Identifiers, Constant, Strings, Operators, etc.Let us begin with Keywords.KeywordsKeywords are predefined, reserved words in C and each of which is associated with specific features. These words help us to use the functionality of C language. They have special meaning to the compilers.There are total 32 keywords in C.autodoubleintstructbreakelselongswitchcaseenumregistertypedefcharexternreturnunioncontinueforsignedvoiddoifstaticwhiledefaultgotosizeofvolatileconstfloatshortunsignedIdentifiersEach program element in C programming is known as an identifier. They are used for naming of variables, functions, array etc. These are user-defined names which consist of alphabets, number, underscore ‘_’. ... Read More
10K+ Views
VariablesIn C language, variables are the storage place where some form of data is stored. Different variables require different amount of memory on which a set of operations is applied.A variable name cannot start with a number. It can consist of alphabets, number, underscore “_”.Here is the syntax of declaring variables in C language, type variable_name;Here is the syntax of multiple variables declaration in C language, type variable_name1, variable_name2, variable_name3;The following is an example of variables in C language, Example Live Demo#include int main() { char a1 = 'H'; int b = 90, c = 150; float ... Read More
4K+ Views
The main reason for segmentation fault is accessing memory that is either not initialized, out of bounds for your program or trying to modify string literals. These may cause a segmentation fault though it is not guaranteed that they will cause a segmentation fault. Here are some of the common reasons for segmentation faults −Accessing an array out of boundsDereferencing NULL pointersDereferencing freed memoryDereferencing uninitialized pointersIncorrect use of the "&" (address of) and "*" (dereferencing) operatorsImproper formatting specifiers in printf and scanf statementsStack overflowWriting to read-only memory
3K+ Views
The compilation of a C++ program consists of three steps −Preprocessing − In simple terms, a C Preprocessor is just a text substitution tool and it instructs the compiler to do required pre-processing before the actual compilation. It handles preprocessing directives like #include, #define, etc.Compilation − The compilation takes place on the preprocessed files. The compiler parses the pure C++ source code and converts it into assembly code. This in turn calls the assembler that converts the assembly code to machine code(binary) as Object files. These Object files can refer to symbols that are not defined. The compiler won't give ... Read More
9K+ Views
A segmentation fault occurs when your program attempts to access an area of memory that it is not allowed to access. In other words, when your program tries to access memory that is beyond the limits that the operating system allocated for your program.Seg faults are mostly caused by pointers that are −Used to being properly initialized.Used after the memory they point to has been reallocated or freed.Used in an indexed array where the index is outside of the array bounds.