Skip to main content


C Programming Basics

1. Introduction to C language: C language was invented in Bell Labs by Dennis Ritchie between 1972-73. C language is a case sensitive language i.e the input given to it varies according to upper and lower case letters. It is executed using binary form data such as (0,1). By using binary data the speed of executing a code increases.
1.1 Header Files:

Header files are those files which contain some predefined functions in it which we are going to use in our code. Every header file is accessed by appending an extension ".h".
Example: #include<stdio.h> ↓                   ⇡
         Tells computer to                  header file with 
         include the header                 extension .h
There are many header files for different functions such as the following: <conio.h><math.h><string.h>Etc.

1.2 Starting of code and basic Syntax:

void main() or int main()

This tells the computer from where the code is starting. It is wri…
Recent posts

Nested Loops In C

Nested Loops In C:Introduction:In this tutorial we are going to learn about Nested Loops. What are Nested Loops ?Importance of Nested Loops.Nested Loop Syntax.Programs on Nested Loops.1. What are Nested Loops ? When a loop is present inside another loop or when multiple loops are present inside a loop then it is called Nested loop.If the outer loop statement is true then the inner loop statement is checked and if it is also true then the code inside the inner loop gets executed.Nested loop is similar to nested if statement the only difference is that a nested loop is executed multiple times till the condition don't becomes false while the nested if statement is executed only once if the condition is true.2. Importance of Nested Loops: Almost all high level programs involves the use of Nested loops.Nested loops are not limited to just themselves but they are also very important to study the further topic of 2-Dimensional array.Various operations in 2-Dimensional array can only be perf…

for loop Programs In C

for loop Programs In C:Q1. Write a C program to find factorial of a number by accepting the number from user. Ans. #include<stdio.h> #include<conio.h> void main() { int n, i, fact=1; clrscr(); printf("\n enter the number for finding factorial"); scanf("%d",&n); for(i=1;i<=n;i++) { fact=fact*i; } printf("\n the factorial of %d is %d",n,fact); getch(); } Output:enter the number for finding factorial 5 the factorial of 5 is 120 Explanation of the above Code:First of all What is factorial? Ans. The symbol of factorial is ! here are example which will give you idea what is factorial ex. 5!=5*4*3*2*1 3!=3*2*1 Now you have the idea what is factorial. In the above code we have declared 3 variables of datatype integer i for the loop, fact=1 for calculating the factorial, n for input.When the loop gets started with i=1 it checks the condition first i.e whether i is less than n (1<=5) which in this case is true since the initial value of i is 1 and the value of n is 5.Afte…

while loop in C

while loop in C:In this session we are going to discuss about while loop and do while loop in C. If you have not red the first session in which I have discussed about for loop the link for the same will be present below this article. 1. while loop in C:As we have seen earlier in for loops it requires initialization, condition, increment or decrement directly after it is declared as shown below. for(initialization, condition, increment) But the same is not true in the case of while loop in while loop the initialization is done first outside the loop, the condition is written after the loop and the increment or decrement operator within the loop.Basic Syntax: int i=1; ← (initialization) while (condition) { code if condition is true; i++;← (increment operator) } Explanation:From the above syntax we can see that the initialization (i=1) is done before the loop is executed.The condition for which loop is executed  is written within parenthesis after writing while.The increment i++ is done when it ent…

switch case in c

switch case in c:What is switch case in c ?It is used for checking the equalityOne switch statement can have multiple case statement.After each case statement break statement is necessary break statement is used for terminating the control from switch case in c.In switch statement default statement is used for displaying the invalid input.Basic Syntax: scanf("%d",x); switch(x) { case 1: code which will be executed when x=1 break; case 0: code which will be executed when x=0 break; case 10: code which will be executed when x=10 break; default : code if any input is invalid } Explanation:In the above syntax the code in case 1 will be executed if the value of x = 1, if x=0 then case 0 will be executed. So in general any thing written after case is compare with the input given by the user ad if it is equal then the code in that case is executed. Note: (:) - should be present after every case statement.Code for switch statement should be written     within curly brackets.break statement should…

for loop in C language

Loops in C language:What are loops?Loops are used for performing a task again and again in other words loops are used for checking number of iterations performed. There are 3 main types of loops in c language. for loopwhile loopdo while loop
We are going to do for loop in this article with some couple of problems.
For executing a loop there are mostly three main steps InitializationConditionIncrement or Decrement operator.1. Initialization:It provides the starting value to the variable to start the loop or the value from where the loop should be started. 2. Condition:It is used for checking the condition if the condition is true than the process is executed until the condition becomes false. 3.Increment or Decrement Operator: It is used for incrementing or decrementing the value variable each time after the loop is executed (i++) -  Increases the value of variable by 1. (i+=1) -  Increases the value of variable by 1. (i=i+1) -  Increases the value of variable by 1. (i=i+2) -  Increases the value …

Nested if Statements In C Programming

NESTED if STATEMENTS:In simple words an if statement inside another if statement is called Nested if statement. Syntax:if(condition 1) { if(condition 2) {code if condition 1 and 2 both are satisfied;} } Example Code:Write a program to find whether the number entered by the user lies in a particular range.
void main()
int n;
printf("\n enter the number ");
printf("\n the entered number is in the given range");

printf("\n the entered number is not in the given range");
printf("\n the number is not in the given range);
The above code is written in code blocks Output:enter the number 17 the entered number is in the given range
Explanation of the above Code: In the above code we have declared an variable of data type integer ('n), the number entered by the user will be stored in this variable.After accepting the number from the user we …

Conditional Statements In C Programming

Conditional Statements:What are conditional Statements:Ans. Conditional statements are those statements which are used to check whether a particular condition is true or t is false and if it is true the task given to it gets executed.
Types of conditional statements:There 3 types of conditional statements
if statementelse if statementelse statement
They all work together to give the desired output.
Syntax: if(condition here) {code to be written here;} Note:The condition which needs to be checked should be written inside the round brackets.Code which needs to be executed if the condition is true is written inside curly braces.Semicolon will come only inside curly braces and not after condition.1. if statement: It is the main statement and it is a standalone statement i.e it doesn't require any other conditional statement for its existence.
Syntax:if(condition){Code to be written here;}If the condition in the above code is true the code within the curly braces get executed. Example Code:#inclu…