C Program To Check Year Is Leap Year or Common Year

Ex: Write a C program to check given year is leap year or common year. How to write a C program to check given year is leap or not. C program to check given year is leap year or common year.


  What  is leap year ?


We all know in the regular year has 365 days.  But in the leap year one day has extra. means leap year has 366 days.



Input from user:

Enter the year: 2020


Expected output:

Given year is leap year.





  Step by step logic of the program:


1. Firstly get input year  from  user. variable say year.

2.  After that use if-else statement to check given condition if(year%400==0) or(year%4==0 and year%100!=0).

3. If above conditions are true then print given year is leap year.

4. Otherwise we print given year is common year.





  C program to check year is leap year or common year :



#include<stdio.h>
int main()
{
int year;

printf("Enter the year\n");
scanf("%d",&year);

if((year%400==0)||(year%4==0 && year%100!=0))
{
printf("Given year is leap year");
}
else
{
printf("Given year is common year");
}

return 0;
}



Above program shows the following output:




C Program to check given number is zero or not

Ex: write to a C program to check given number is zero or not. C program to check given number is zero or not. How to write a C program to print it is zero or not.


Input from user:

Enter the number: 0

Expected output: 

Given number is zero.



  Step by step logic of the given program:


1. First we will accept input number from user say no.

2.  After that use if-else statement to check condition no==0 .

3. If this condition true then print given number is zero.

4. Otherwise we print given number is not zero.



  C  Program to check given number is zero or not :


#include<stdio.h>
int main()
{
int no;

printf("Enter the number\n");
scanf("%d",&no);

if(no==0)
{
printf("Given number is zero");
}
else
{
printf("Given number is not zero");
}
return 0;
}



Above program  shows the following output:






C Program to Find Maximum Between Three Numbers

EX: write a C program to check maximum number between three numbers. C program to print Maximum  between three numbers. How to write a C program to print Maximum  between three numbers.

In previous program we learn how to find maximum between two numbers. In this program we will find maximum between three numbers.



Input from user:

Enter the number 1: 100

Enter the number 2: 500

Enter the number 3: 300


Expected output:

Maximum between three numbers is: 500

So let's get explore it's logic.




  Step by step logic of the given program:


1. Accept three numbers from user say no1, no2 and no3.

2. Use if-else-if ladder and relational operators to find this .

3. Check if no1>no2 and no1>no3 if true means no1 is maximum.

4. If this condition is not true then we check no2>no1 and no2>no3 if this condition true then no2 is maximum.

5. Otherwise we will print no3 is maximum.





  C program to find maximum between three numbers:


#include<stdio.h>

int main()
{
int no1,no2,no3;

printf("Enter number 1:\n");
scanf("%d",&no1);

printf("Enter number 2:\n");
scanf("%d",&no2);

printf("Enter number 3:\n");
scanf("%d",&no3);

if(no1>no2&&no1>no3)
{
printf("Maximum number is %d",no1);
}
else if(no2>no1&&no2>no3)
{
printf("Maximum number is %d",no2);
}
else
printf("Maximum is %d",no3);

return 0;

}



Above program shows the following output:


C program to find maximum between three numbers


C program to check given number is maximum or equal between two numbers

Ex: write a C program to check number is maximum, minimum or equal between two numbers. How to write a C program to print number is maximum or equal between two numbers. C program to check number is maximum or equal between two numbers.

Input from user:

Enter the 1st number: 55

Enter the 2nd number: 25

Expected Output:

Number  55 is greater than 25




  Step by step logic of the given program:


1. First we will accept 1st number from user which is 55.


2. After that we will accept 2nd number from user which is 25.

3. After that we use if-else statement or relational operators to check number is maximum or equal.

4. If number 1 means a greater than number 2- b then we will print a is greater than b.

5. If number 2 means b is greater than a then  we print b is greater.

6. Otherwise we will print two numbers are equal.




  C program to check given number is maximum | minimum or equal between two numbers:


#include<stdio.h>
int main()
{
int a,b;

printf("Enter the 1st number\n");
scanf("%d",&a);

printf("Enter the 2nd number\n");
scanf("%d",&b);

if(a>b)
{
printf("Number %d is greater than %d",a,b);
}
else if(b>a)
{
printf("Number %d is greater than %d",b,a);
}
else
{
printf("Given Two numbers are equal\n");
}
return 0;
}


Above program shows the following output:


C program to check given number is maximum | minimum or equal between two numbers




If-Else-If statement in C

   If-else-if Statement:


In C if-else-if ladder is used to decide from among multiple options. 
It means if-else-if ladder is a way of putting multiple if's together, So by using it we can check multiple conditions.


  Syntax of if-else-if ladder:


if(condition 1)

{
     //block of statements;
}
else if(condition 2)
{
    //block of statements;
}
else if(condition 3)
{
    //block of statements;
     .
     .
     //upto n statements;

}
else
{
    // default statement;
}


Above syntax shows the working of if-else-if ladder in C programming language.

To explore if -else statements examples Click Here.


Nested If-else statement in C

   Nested If-else :

Nested if-else statement means you can use one if-else statement inside the another if-statement. It is used when you want to add conditions in if statement.


  Syntax of Nested If-else statements:


if(condition 1)

{

    if(condition 2)

    {
        //block of statements;
    }
    else
    {
       //block of statements;
    }
}
else
{
    //block of statements;
}
.
.


In above syntax we used if-else statement in the body of another if-statement. It shows the working of  Nested If-else statement.

To explore if-else statements examples and solutions Click Here.

If-else statement in C

If-else: statements are used to control the flow of Program based on some conditions, only the difference is it is used to execute some statement code blocks. if the expression is evaluated to true, otherwise it executes else block. Which is shown in below flow chart.





  Syntax:

if(condition)
{
       //block of statements;
}
else
{
      //block of statements;
}


Above syntax shows the working of if-else statement.


To explore if-else statements examples and their solutions Click Here.

If statement in C

When we need to enter the block only when given condition is true then we use if-statement. means we enter the if block only if given condition is true.



  Synatx of if-statement:


if(condition)
{
               .
               .
      // block of Statements
;
}


Above syntax shows the working of if-statement. Which shows when if condition is true then it enters in if's block. Otherwise it goes outside the if block.
Let know more about if-statement with one example:


#include<stdio.h>
void main()
{

int a=15;

     if(a>10)
     {
printf("a is greater than 10");
     }

}


Above program shows the following output:




Classification of the programming languages

There are many programming languages which are used to  instruct the computer to perform various tasks.
Basically programming language defines a set of instructions that are compiled together to perform a specific task by the CPU.


Classification of the programming languages

Programming languages are basically devided into 3 types:

1. LOW level language

2. Middle level language
3. High level language

Which is shown in above image.


The image which is given below describes the abstraction level of hardware. Which shows  level of abstraction of languages.



Classification of the programming languages




  • Low level language is contains basic instructions recognised by a computer.
   Low level language is not human readable. It has basically two types:
1. Assembly language
2. Machine language 

1. Assembly language is one step closer to a high level language than machine language. In this language includes some commands such as MOV(move), ADD(add), & SUB(subtract) etc. commands are used in this type of language.

2. Machine level language is also called as low level language because data writen in this language is 0's and 1's binary format.

  • Middle level language: The best example of middle level language is C programming language because using C programming language we can do both system and application programming.

  • Hight level language is easily understoodable compared than machine level language or assembly language. It is programmer friendly language.
 Some Examples of high level language:
C, C++, Java, python etc....

What Is Programming

what is programming, learn programming, programming, coding

In simple words programming is a way to instruct the computer to perform various tasks.
Programming is the process of designing and building an executable computer program to accomplish a specific computing result.


That means you can use programming languages  like C, C++, Java, C#, Python, JavaScript etc.. to create a list of instructions for a computer to follow.

This simply means that you can provide the computer a set of instructions that are written in any programming languages i.e, C, C++, java, python etc..etc. that computer can understand easily.

You can give following type of instructions to a computer using programming languages. 

The above examples come under basic instructions. 

Programming languages are used for a wide range of purposes, like: Software Development, Web Development, Data Analysis & Data Science, Artificial Intelligence(AI) and Machine Learning, Game Development, Mobile Apps Development and many more.