Union in C Programming

In C programming language, union is a special user defined data type that allows to store different data types in the same memory location. “union”  uses the same memory location for multiple-purpose.  Or In a union data type, single variable, i.e., same memory location, can be used to store multiple types of data. In c programming … Read more

Structures in C Programming

There are various types of data type such as int, char float etc. For example:  int  i;      here variable i can store only data of integer type            char c;   here variable c can store only data of character type           float  f; here variable f can store only data of floting-point type … Read more

File handling programs in C Programming

Example : Write a C program to copy the contents of one file to another file. #include #include // For exit() int main() { FILE *fp1, *fp2; // Declare two file pointer fp1 & fp2 char filename[50], c; printf(“Enter the filename to open for reading “); scanf(“%s”, filename); fp1 = fopen(filename, “r”); // Open file for … Read more

Writing to a File in C Programming

To write on a file there are following  function available:  Function fputc() : function fputc() write individual characters at a time to the file. The syntax of this function is – Syntax :                int  fputc( int c,  FILE *fp ); Function fputc()  returns the written character written on success and  if there is an error it will return … Read more

File Handling in C Programming

A file represents a sequence of bytes and these file’s is used to store information. There are various different operations that we can be performed on a file are: Creation of a new file (fopen with attributes as “a” or “a+” or “w” or “w++”) Opening an existing file (fopen) Reading from file (fscanf or … Read more

Arithmetic Operation With Pointer

In a C programming, we can also perform arithmetic operations with pointer. There are four arithmetic operators that can be performed with pointers: Increment (++) Decrement ( — ) Addition ( + ) Subtraction ( – )  For a simple variable int a=3;a++; //print 4Increment integer value by one. Pointer is a variable which can … Read more

Loops in C Programming

In a programming often a situation may comes where we want to  execute the set of code again and again. Loop has a ability to repeat set of statement until a condition to be satisfied or a particular number of times. There are following types of  loop in C language: In a C programming language … Read more

Difference between structure and union in C Programming

In C programming, both structures (structs) and unions are used to define custom data types that can hold multiple variables of different data types. However, they have distinct differences in terms of how they allocate memory and how they store data: 1. Memory Allocation: 2. Memory Usage: 3. Accessing Data: 4. Use Cases: Aspect Structure … Read more

History of C Programming

C is computer programming language developed in 1972 by Dennis M. Ritchie. C programming language developed in  Bell Laboratories to develop the UNIX operating system. C is a  high-level language which can be easily read and written by any one. C is a case-sensitive programming language. Thus, “HELLO” and “Hello” two different identifiers in C.

Primitive Data Types in C Programming

1. What is data type in C Data type specifies what type of data a variable can hold. There are four category of data type in C language.  They are as follows: Types Data Types Basic (Primitive) data types int, char, float, double Enumeration data type Enum Derived data type pointer, array, structure, union Void … Read more