Category Archives: C Tutorials

Difference between Macro and Function

In this post, we are going to understand difference between macro and function. But before getting started, I want to explain little bit about macro and function to you in an easy way. What is a function? A function can be stated as a group of statements that performs some kind of task. In every… Read More »

Difference between while and do while Loop

Here you will get to know about difference between while and do while loop. Both while and do while loops are used to execute set of statements multiple times. But there are some differences between them in terms of syntax and working that I have discussed below. Difference between while and do while Loop while… Read More »

Difference between float and double

Here you will learn about difference between float and double i.e. float vs double. These are two commonly used floating point data types in programming languages like C, C++, Java, etc. Both float and double are used to store values with decimal point but there are some differences between them that are mentioned below. float… Read More »

How to Convert String to int in C and C++

There are different ways to convert string to int in C and C++. Like using inbuilt function or writing custom code. Lets take a look on each of them one by one. The programs below are written in C but the same concept will work for C++. Ways to Convert String to int in C… Read More »

Difference between Declaration and Definition in C

Mostly beginner programmers are not aware of difference between declaration and definition in C. In this tutorial I will explain the both terms clearly. Declaration It tells compiler about the name and type of the identifier (variable, function, array, etc.). Memory is not reserved in this case. Variable Declaration

In above example we declared… Read More »

Solve error: lvalue required as left operand of assignment

In this tutorial you will know about one of the most occurred error in C and C++ programming, i.e. lvalue required as left operand of assignment. lvalue means left side value. Particularly it is left side value of an assignment operator. rvalue means right side value. Particularly it is right side value or expression of an assignment… Read More »

Lexical Analyzer in C and C++

Here you will get program to implement lexical analyzer in C and C++. Compiler is responsible for converting high level language in machine language. There are several phases involved in this and lexical analysis is the first phase. Lexical analyzer reads the characters from source code and convert it into tokens. Different tokens or lexemes… Read More »

How to Generate Random Number in C and C++?

Here you will get program and learn how to generate random number in C and C++. We can use rand() function to generate random number. It is defined in stdlib.h header file. It generates a random number between 0 and RAND_MAX (both inclusive). Here RAND_MAX is a constant whose value depends upon the compiler you are… Read More »