Write a C program to demonstrate input and output of all basic and derived types. How to use
printf() function perform input and output on primitive types in C programming.
Continue reading C program to perform input output of all basic data types
Input, process and output processed data is the main goal of every computer program. A program without data is a useless program.
In this post we will learn some basic C functions to input and output value of a variable.
Continue reading Basic input and output in C
Typecasting is a way to convert variables, constants or expression from one type to another type. Conversion from one type to another is often required in programming.
Consider a case where you want to find average of three numbers. Let us write a program to find average of three numbers.
int num1, num2, num3;
num1 = 91;
num2 = 85;
num3 = 83;
average = (num1 + num2 + num3) / 3;
printf("Average = %f", average);
Continue reading Typecasting in C programming
Constants are fixed value variables, whose value cannot be altered throughout the execution of program. The fixed value is known as literal.
You can define a constant for any type. They behave like normal variables expect that they are readonly (once assigned cannot be modified).
Continue reading Defining Constants in C
Variables are used to represent some known or unknown quantity in memory. Variables are referential name given to memory location holding our program data.
C variables are typed in nature, means we must explicitly specify data type of the variable at the time of its declaration.
Continue reading Variables and expressions in C programming
In the series of learning programming, we learned about data types. Data type is a system for defining various properties of data stored in memory. Properties such as, type of data, range of data, bytes occupied etc.
Data type in C programming is categorized three categories.
- Primitive data type
- Derived data type
- User defined type
Read more - List of all format specifiers in C
Continue reading List of all data types in C programming
In C programming data types play a major role, so is their size and range. The
sizeof() operator gives you bytes required to store value of some type in memory. However, in programming you must be aware of range of a type to avoid overflow and underflow errors.
The size of a data type is compiler dependent and so is its range. So, you must not hardcode size and range values in your program.
There are two ways to find minimum and maximum range of a type. You can use any of the approach to get range of a type.
Continue reading How to find range of data types in C programming?
Size of a data type is machine dependent and vary from compiler to compiler. However, in programming there exists situations when we need to know total bytes a type occupies in memory. To find exact size of a type in C programming we use
sizeof() is a special operator used to find exact size of a type in memory. The
sizeof() operator returns an integer i.e. total bytes needed in memory to represent the type or value or expression.
sizeof() is much used operator by programmers. It is very useful for developing portable programs.
Continue reading sizeof() operator in C programming
Data type is a system for defining various basic properties about the data stored in memory. Properties such as, type of data, range of data, bytes occupied, how these bytes are interpreted etc.
int is a data type used to define integer type variables.
int a; here a is an integer type variable. It can store numbers from -2,147,483,648 to +2,147,483,647.
Data types in C is classified in three broad categories.
Continue reading Data types in C programming
Comment is non-executable line in source code used to describe a piece of code or program. Comments provides inline documentation of source code and enhances readability of the code. It describes what a piece of code does.
Comments are for readers not for compilers. They make source code more developer friendly.
The compiler has nothing to do with comments, it is non-executable piece of code. Therefore, during the compilation process, pre-processor removes all comments from the source code.
Continue reading Comments in C programming