Different data - types used in C language

 In this I tell every thing about data-types in C language . So do not waste our time let's get's started. After reading this your all doubt about data-types get clear. 

We generally use three types of data-types in  C language that is Int Float Char . Let us  talk about each 

1.Int :Int as the name suggest is used to store integer data-types in C language . It is used  to store number like : 34,41 , etc.

2.float : It is used to store floating points number that in simple means decimal number .It store number like 2.3,4.3 ,etc.

3. Char : It is used to store single character in  C language . Like 'c' ,'d', etc.

Other than these we also have some more data - types . That we hardly use Like short int , long int ,double , long double ,etc.

Short Int: Like int it also store   integer but  2 bytes.

Long Int : Like int it also store  integer but use 4 bytes.

Double : Double is similar to float but it  store generally 8 bytes.

Long Double: There is no difference between double and long double it is just matter of bytes used it generally use 10 bytes.

Important:

How much  bytes does data -type is depends on machine you are using and compiler you are using .

                                                           Table 

            Data-types                                                            Symbol used

              Int                                                                             %d

             Float                                                                           %f

              char                                                                            %c

               Double                                                                       %lf

               Long Int                                                                     %ld

              Long Double                                                                 %Lf

             short Int                                                                             %d

These are the various symbols used in C language to take input and print output . We very careful about the symbols used . As these are case-sensitive .

  I hope you find this helpful in your work .

  Thanks for  reading 


Sum of Five digit number

 In this I will tell you how to do sum of five digit number . So, without any further delay let's get started .Like our previous post we here going to use all three loops in C .

Code:

Using for loop

#include <stdio.h>
//sum of five digit number using loop
int main()
{
    int number;
    printf("Enter any  five digit number\n");
    scanf("%d", &number);
    int sum = 0;
    int number1;
    for (int i = 0i < 5i++)
    {
        number1 = number % 10;
        sum = sum + number1;
        number = number / 10;
    }
    printf("%d \n"sum);
    return 0;
}

Using while loop 

#include <stdio.h>
//sum of five digit number using loop
int main()
{
    int number;
    printf("Enter any  five digit number\n");
    scanf("%d", &number);
    int sum = 0;
    int number1;
    int i=0;
    while(i<5){
        number1 = number % 10;
        sum = sum + number1;
        number = number / 10;
        i++;
    }
    printf("%d \n"sum);
    return 0;
}

Using do-while loop 

#include <stdio.h>
//sum of five digit number using loop
int main()
{
    int number;
    printf("Enter any  five digit number\n");
    scanf("%d", &number);
    int sum = 0;
    int number1;
    int i=0;
    do{
        number1 = number % 10;
        sum = sum + number1;
        number = number / 10;
        i++;
    }while(i<5);
    
    printf("%d \n"sum);
    return 0;
}

Logic:

First we define Variable of  type int   that is number  and we take input of five digit number from user in this . Then we define another variable of type int  that is number1 and sum=0. we give sum as value zero. In number1 we assign value number%10 that means remainder remains  after dividing five digit number with 10. And then we add it in sum variable . And Then we divide number by 10 in order to get quotient and store in same variable number .This happens five times  and loop gets exit.

Output:

 You can give different input to this program and check by yourself. And please try by yourself  .

  I hope that you find this helpful in you work . 

Thanks for reading .









Multiplication Table of any number

 In this I will let You know how to create a multiplication table of   the number you want .So, without any time waste .What we are going to use here .We here use loop. Then question come what is loop for understanding let me give you example if you want to print 1000 natural numbers for that you are  not going to  print one by one in order to save time. For this we just create a loop condition after which it exit and then increase it one by one .

Code:

Multiplication table using While loop

#include<stdio.h>
//to print multiplication table of any number
int main(){
    
    int number;
    int i=1;//we here intilize it form one 
    printf("Enter Number for Multiplication table\n");
    scanf("%d",&number);
    while(i<=10){
        printf("%d X %d = %d\n",number,i,number*i);
        i++;
    }

    return 0;
}

Multiplication Table using for loop

#include<stdio.h>
//to print multiplication table of any number
int main(){
    
    int number;
    int i=1;//we here intilize it form one 
    printf("Enter Number for Multiplication table\n");
    scanf("%d",&number);
    for(i=1;i<=10;i++){
        printf("%d x %d = %d\n",number,i,number*i);
    }

    return 0;
}

Multiplication Table using do-while loop

#include<stdio.h>
//to print multiplication table of any number
int main(){
    
    int number;
    int i=1;//we here intilize it form one 
    printf("Enter Number for Multiplication table\n");
    scanf("%d",&number);
    do{
        printf("%d x %d = %d\n",number,i,number*i);
        i++;
    }while(i<=10);

    return 0;
}

Logic:

Now you can see here we first declare Variable of type int  number .And we take input form user in it and also define i initialize i it form 1. And increase value of i every time till i less than equal to  10. After this we just do multiplication of  given number from user by value of i. And it will print us multiplication table.

Output:


You can see here I give 12 as input  and program here give us multiplication table of  12. You can check out this on your own pc .I hope you find this helpful to  you in your work .

Thanks for reading 




C program to check Even or Odd

 In this post ,I will tell you how to make a C program which can check a Integer entered by the user is Even OR Odd  . So, without any further delay let's get started.

Code:

#include <stdio.h>

int main()
{

    int Integer;
    printf("Enter any Integer to check for Even or Odd \n");
    scanf("%d", &Integer);
    if (Integer % 2 == 0)
    {
        printf("It is a Even number\n");
    }
    else
    {
        printf("It is a Odd number\n");
    }

    return 0;
}


Logic:
First let us understand what is even number and what is odd number. Even number is any number that completely divisible by 2 means leaves remainder zero. And odd number is one which does not completely divides itself by 2 means leaves something in remainder.  Now let us see code of this and understand it in language of coder. Now you have understand what is even and what is odd number .It time to understand above code .For this we first declare variable name Integer of type int. To store integer values then we print statement "Enter any integer to check Even or odd" using printf() .And store value entered by user in Integer variable . And now we use if(Integer%2==0) means if remainder by dividing Integer is 2  comes out to be zero .Then it is a Even number and using printf( ) function we print    ."It is Even Number" .If this condition is false that means it is odd number .And we print it .

Output:                                                                                                     



You can see output here it works as we guess .First we enter 33 which is odd number and it gives us odd.  When we give 6 which is even number we all know and it gives us even number.
I hope you find this helpful in your work .
Thanks for reading .