Monday, February 15, 2016

C Program to find maximum and minimum element in a array of 5 elements.

/*=================================================================================
 **
 **  File Name     : maxMinArray.c
 **  Creation Date : Tue 16 Feb 2016 03:23:54 AM IST
 **  Last Modified : Tue 16 Feb 2016 03:41:23 AM IST
 **  Compoler      : gcc
 **  Author        : Manoj Kumar Patra, manojpatra.sit@gmail.com
 **  Organization  : SCIS, University of Hyderabad, India.
 **
 **===============================================================================*/

#include<stdio.h>
int main ()
{
    printf("\n= = = = = Find bigest and Smallest elements in an array = = = =\n");
    int arr[5], i;
    printf("\nEnter the elements of the array : \n");
    for(i=0; i<5; i++)
    {
        scanf("%d", &arr[i]);
    }
    printf("\nThe elements of the array are : \n");
    for(i=0; i<5; i++)
    {
        printf("%d\t",arr[i]);
    }
    int max = arr[0];
    int min = arr[0];
    for (i = 0; i < 5; i++)
    {
        if (arr[i] > max)
        {
            max = arr[i];
        }
        else if (arr[i] < min)
        {
            min = arr[i];
        }
    }
    printf ("\nThe biggest element of the array : %d\n", max);
    printf ("\nThe smallest element of the array : %d\n", min);
    printf("\n= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =\n\n");
    return 0;
}

Output :
max@ubuntu:~/cprog$ gcc maxMinArray.c -o maxMinArray
max@ubuntu:~/cprog$ ./maxMinArray

= = = = = Find bigest and Smallest elements in an array = = = =

Enter the elements of the array :
3
2
4
5
1

The elements of the array are :
3    2    4    5    1   
The biggest element of the array : 5

The smallest element of the array : 1

= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

C Program to find the biggest and smallest of three numbers.

/*=================================================================================
**
**  File Name     : bigSmall.c
**  Creation Date : Tue 16 Feb 2016 03:03:35 AM IST
**  Last Modified : Tue 16 Feb 2016 03:20:17 AM IST
**  Compoler      : gcc
**  Author        : Manoj Kumar Patra, manojpatra.sit@gmail.com
**  Organization  : SCIS, University of Hyderabad, India.
**
**===============================================================================*/

#include<stdio.h>
void main()
{
    printf("\n= = = = = = Big and Small among 3 number = = = = =\n");
    int n1, n2, n3, big, small;
    printf("\nEnter The first number : ");
    scanf("%d", &n1);
    printf("\nEnter The second number : ");
    scanf("%d", &n2);
    printf("\nEnter The third number : ");
    scanf("%d", &n3);

    printf("--------------------------------------------------\n");
    if(n1>n2 && n1>n3)
    {
        big=n1;
    }
    else if(n2 > n3)
    {
        big=n2;
    }
    else
    {
        big=n3;
    }
    printf("\nThe biggest number is : %d\n",big);
    if(n1<n2 && n1<n3)
    {
        small= n1;
    }
    else if(n2 < n3)
    {
        small = n2;
    }
    else
    {
        small=n3;
    }
    printf("\nThe smallest number is : %d\n",small);
    printf("\n= = = = = = = = = = = = = = = = = = = = = = = = =\n\n");
}

Output :

max@ubuntu:~/cprog$ gcc bigSmall.c -o bigSmall
max@ubuntu:~/cprog$ ./bigSmall

= = = = = = Big and Small among 3 number = = = = =

Enter The first number : 34

Enter The second number : 23

Enter The third number : 67
--------------------------------------------------

The biggest number is : 67

The smallest number is : 23

= = = = = = = = = = = = = = = = = = = = = = = = =

C Program to calculate sum of all elements in an Array

/*=================================================================================
 **
 **  File Name     : sumArray.c
 **  Creation Date : Tue 16 Feb 2016 02:47:54 AM IST
 **  Last Modified : Tue 16 Feb 2016 02:57:53 AM IST
 **  Compoler      : gcc
 **  Author        : Manoj Kumar Patra, manojpatra.sit@gmail.com
 **  Organization  : SCIS, University of Hyderabad, India.
 **
 **===============================================================================*/

#include<stdio.h>
int main()
{
    printf("\n= = = = = = Sum of Array elements = = = = =\n");
    int arr[100], n, i, sum=0;
    printf("\nHow many elements you wanna Store : ");
    scanf("%d", &n);
    printf("\nEnter the values into array :\n");
    for (i=0; i<n; i++)
    {
        scanf("%d", &arr[i]);
    }
    for (i=0; i<n; i++)
    {
        sum = sum + arr[i];
    }
    printf("\nSum of all the numbers in the array = %d\n", sum);
    printf("\n= = = = = = = = = = = = = = = = = = = = = = =\n\n");
    return (0);
}

Output :

max@ubuntu:~/cprog$ gcc sumArray.c -o sumArray
max@ubuntu:~/cprog$ ./sumArray

= = = = = = Sum of Array elements = = = = =

How many elements you wanna Store : 5

Enter the values into array :
1
2
3
4
5

Sum of all the numbers in the array = 15

= = = = = = = = = = = = = = = = = = = = = = =

C Program to find max and min between two numbers.

/*=================================================================================
 **
 **  File Name     : maxmin.c
 **  Creation Date : Tue 16 Feb 2016 01:09:26 AM IST
 **  Last Modified : Tue 16 Feb 2016 02:33:46 AM IST
 **  Compoler      : gcc
 **  Author        : Manoj Kumar Patra, manojpatra.sit@gmail.com
 **  Organization  : SCIS, University of Hyderabad, India.
 **
 **===============================================================================*/

#include<stdio.h>
int main() 
{
    printf("\n= = = = = = Find max and min between two numbers = = = = = =\n\n");
    int num1, num2; 
    printf("Enter the first numbers : "); 
    scanf("%d", &num1); 
    printf("Enter the second numbers : "); 
    scanf("%d", &num2); 
    if(num1 > num2) 
    { 
        printf("\n%d is Maximum.\n", num1);
        printf("%d is Minimum.\n",num2);
    } 
    else 
    { 
        printf("\n%d is maximum.\n", num2); 
        printf("%d is Minimum.\n",num1);
    } 
    printf("\n= = = = = = = = = = = = = = = = = = = = = = = = = = = = = =\n\n");
    return 0; 
}

Output :

max@ubuntu:~/cprog$ gcc maxmin.c -o maxmin
max@ubuntu:~/cprog$ ./maxmin

= = = = = = Find max and min between two numbers = = = = = =

Enter the first numbers : 450
Enter the second numbers : 650

650 is maximum.
450 is Minimum.

= = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

C Program to check Even or Odd

/*=================================================================================
 **
 **  File Name     : evenodd.c
 **  Creation Date : Tue 16 Feb 2016 12:55:54 AM IST
 **  Last Modified : Tue 16 Feb 2016 01:02:17 AM IST
 **  Compoler      : gcc
 **  Author        : Manoj Kumar Patra, manojpatra.sit@gmail.com
 **  Organization  : SCIS, University of Hyderabad, India.
 **
 **===============================================================================*/

#include <stdio.h>
int main()
{
    printf("\n= = = = = Program to check Even or Odd = = = = = = =\n");
    int n;
    printf("\nEnter an integer : ");
    scanf("%d", &n);
    if(n%2 == 0)
    {
        printf("\nThe entered number %d is a Even number.\n",n);
    }
    else
    {
        printf("\nThe entered number %d is a Odd number.\n",n);
    }
    printf("\n= = = = = = = = = = = = = = = = = = = = = = = = = = =\n\n");
    return 0;
}

OutPut :

max@ubuntu:~/cprog$ gcc evenodd.c -o evenodd
max@ubuntu:~/cprog$ ./evenodd

= = = = = Program to check Even or Odd = = = = = = =

Enter an integer : 23

The entered number 23 is a Odd number.

= = = = = = = = = = = = = = = = = = = = = = = = = = =

max@ubuntu:~/cprog$ ./evenodd

= = = = = Program to check Even or Odd = = = = = = =

Enter an integer : 46000

The entered number 46000 is a Even number.

= = = = = = = = = = = = = = = = = = = = = = = = = = =

C Program to convert a decimal Number into binary

/*=================================================================================
 **
 **  File Name     : decToBin.c
 **  Creation Date : Mon 15 Feb 2016 10:10:36 PM IST
 **  Last Modified : Mon 15 Feb 2016 10:24:09 PM IST
 **  Compoler      : gcc
 **  Author        : Manoj Kumar Patra, manojpatra.sit@gmail.com
 **  Organization  : SCIS, University of Hyderabad, India.
 **
 **===============================================================================*/

#include <stdio.h>
#include <math.h>
int main()
{
    printf("\n= = = = = = = Decimal to Binary = = = = = = = = =\n");
    int n, bin=0, rem, i=1, k;
    printf("\nEnter a decimal number : ");
    scanf("%d", &n);
    k=n;
    while (n!=0)
    {
        rem=n%2;
        n/=2;
        bin+=rem*i;
        i*=10;
    }
    printf("\nThe binary equivalent of %d is = %d\n",k,bin);
    printf("\n= = = = = = = = = = = = = = = = = = = = = = = = =\n\n");
}

OutPut :

max@ubuntu:~/cprog$ gcc decToBin.c -o decToBin
max@ubuntu:~/cprog$ ./decToBin

= = = = = = = Decimal to Binary = = = = = = = = =

Enter a decimal number : 100

The binary equivalent of 100 is = 1100100

= = = = = = = = = = = = = = = = = = = = = = = = =

max@ubuntu:~/cprog$ ./decToBin

= = = = = = = Decimal to Binary = = = = = = = = =

Enter a decimal number : 15

The binary equivalent of 15 is = 1111

= = = = = = = = = = = = = = = = = = = = = = = = =

Program to count the number of digits in a integer Number.

/*=================================================================================
**
**  File Name     : countDigit.c
**  Creation Date : Mon 15 Feb 2016 09:18:11 PM IST
**  Last Modified : Mon 15 Feb 2016 09:33:57 PM IST
**  Compoler      : gcc
**  Author        : Manoj Kumar Patra, manojpatra.sit@gmail.com
**  Organization  : SCIS, University of Hyderabad, India.
**
**===============================================================================*/

#include<stdio.h>
int main()
{
    printf("\n= = = = = = = = Count the Number of digits = = = = = = = = =");
    int no, count=0;
    printf("\nEnter the number to count the digits : ");
    scanf("%d", &no);
    int k=no;
    while(no)
    {
        no = no/10;
        count++;
    }
    printf("\nThe number of digits present in %d is : %d\n",k, count);
    printf("\n= = = = = = = = = = = = = = = = = = = = = = = = = = = = =\n\n");
}

Output:

max@ubuntu:~/cprog$ gcc countDigit.c -o countDigit
max@ubuntu:~/cprog$ ./countDigit

= = = = = = = = Count the Number of digits = = = = = = = = =
Enter the number to count the digits : 467913

The number of digits present in 467913 is : 6

= = = = = = = = = = = = = = = = = = = = = = = = = = = = =

C Program to print the digits of a number in reverse order.

/*=================================================================================
**
**  File Name     : revDigit.c
**  Creation Date : Mon 15 Feb 2016 09:18:11 PM IST
**  Last Modified : Mon 15 Feb 2016 09:42:45 PM IST
**  Compoler      : gcc
**  Author        : Manoj Kumar Patra, manojpatra.in@gmail.com
**  Organization  : SCIS, University of Hyderabad, India.
**
**===============================================================================*/

#include<stdio.h>
int main()
{
    printf("\n= = = = = = = = = Reverse the Number = = = = = = = = = = =");
    int no, rev, rem;
    printf("\nEnter the number to be reversed : ");
    scanf("%d", &no);
    while(no)
    {
        rem = no%10;
        no = no/10;
        //printf("%d",rem);
        rev = (rev*10)+rem;
    }
    printf("\nThe reverse number of %d is : %d\n",no, rev);
    printf("\n= = = = = = = = = = = = = = = = = = = = = = = = = = = = =\n\n");
}

Output:

max@ubuntu:~/cprog$ gcc revDigit.c -o revDigit
max@ubuntu:~/cprog$ ./revDigit

= = = = = = = = = Reverse the Number = = = = = = = = = = =
Enter the number to be reversed : 12345

The reverse number of 0 is : 54321

= = = = = = = = = = = = = = = = = = = = = = = = = = = = =

C Program to reverse the elements of an integer array.

/*=================================================================================
 **
 **  File Name     : reverseArray.c
 **  Creation Date : Mon 15 Feb 2016 07:48:58 AM IST
 **  Last Modified : Mon 15 Feb 2016 08:13:49 AM IST
 **  Compoler      : gcc
 **  Author        : Manoj Kumar Patra, manojpatra.in@gmail.com
 **  Organization  : SCIS, University of Hyderabad, India.
 **
 **===============================================================================*/

#include <stdio.h>
int main()
{
    printf("\n= = = = = = = = Reverse the Array Elements = = = = = = = = =");
    int arr[100], n, i, k, temp;
    printf("\nHow many elements you wanna insert in to array : ");
    scanf("%d", &n);
    printf("Enter the elements in to array : \n");
    for (i = 0; i < n ; i++)
    {
        scanf("%d", &arr[i]);
    }
    printf("\nThe original elements of the array are : \n");
    for (i = 0; i < n ; i++)
    {
        printf("%d\t", arr[i]);
    }
    printf("\n-----------------------------------------------------------\n");
    k = n-1;
    for(i=0; i<k; i++)
    {
        temp=arr[i];
        arr[i]=arr[k];
        arr[k]=temp;
        k--;
    }
    printf("\nThe Reversed array elements are : \n");
    for (i=0; i<n; i++)
    {
        printf("%d\t", arr[i]);
    }
    printf("\n\n= = = = = = = = = = = = = = = = = = = = = = = = = = = = = =\n\n");
    return 0;
}

Output:

max@ubuntu:~/cprog$ gcc reverseArray.c -o reverseArray
max@ubuntu:~/cprog$ ./reverseArray

= = = = = = = = Reverse the Array Elements = = = = = = = = =
How many elements you wanna insert in to array : 8
Enter the elements in to array :
1
2
3
4
5
6
7
8

The original elements of the array are :
1    2    3    4    5    6    7    8   
-----------------------------------------------------------

The Reversed array elements are :
8    7    6    5    4    3    2    1   

= = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

C Program to remove duplicate elements from an integer array.

/*=================================================================================
**
**  File Name     : delDuplicate.c
**  Creation Date : Wed 14 Feb 2016 07:38:32 PM IST
**  Last Modified : Mon 15 Feb 2016 07:22:57 AM IST
**  Compoler      : gcc
**  Author        : Manoj Kumar Patra, manojpatra.in@gmail.com
**  Organization  : SCIS, University of Hyderabad, India.
**
**===============================================================================*/

#include<stdio.h>
int main()
{
    printf("\n= = = = = = = = Remove duplicate elements from Array = = = = = = = = =\n");
    int arr[100], i, j, n, k;
    printf("\nHow many elements you wanna insert : ");
    scanf("%d", &n);
    printf("\nInsert the elements in to the array:\n");
    for(i=0; i<n; i++)
    {
        scanf("%d", &arr[i]);
    }
    printf("\nThe elements of the array before deleting duplicate elements:\n");
    for(i=0; i<n; i++)
    {
        printf("%d\t", arr[i]);
    }
    printf("\n-----------------------------------------------------------------------\n");
    for(i=1; i<n; i++)
    {
        //item= arr[i];
        int count=0;
        for(j=i-1; j>=0; j--)
        {
            if(arr[i]==arr[j])
            {
                for(k=i; k<n; k++)
                {
                    arr[k]=arr[k+1];
                }
                n=n-1;
            }
        }
    }
    printf("The elements of the array after deletion of duplicate elements:\n");
    for(i=0; i<n; i++)
    {
        printf("%d\t",arr[i]);
    }
    printf("\n= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =\n\n");
}

Output:

max@ubuntu:~/cprog$ gcc delDuplicate.c -o delDuplicate
max@ubuntu:~/cprog$ ./delDuplicate

= = = = = = = = Remove duplicate elements from Array = = = = = = = = =

How many elements you wanna insert : 6

Insert the elements in to the array:
2
4
3
4
5
4

The elements of the array before deleting duplicate elements:
2    4    3    4    5    4   
-----------------------------------------------------------------------
The elements of the array after deletion of duplicate elements:
2    4    3    5   
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

C Program to merge two array in ascending order.

/*=================================================================================
 **
 **  File Name     : merge2array.c
 **  Creation Date : Mon 15 Feb 2016 06:12:36 AM IST
 **  Last Modified : Mon 15 Feb 2016 06:42:13 AM IST
 **  Compoler      : gcc
 **  Author        : Manoj Kumar Patra, manojpatra.in@gmail.com
 **  Organization  : SCIS, University of Hyderabad, India.
 **
 **===============================================================================*/

#include <stdio.h>
int main()
{
    printf("\n= = = = = = = = = Merge the elements of two array = = = = = = = = =\n");
    int arr1[100], arr2[100], sorted[200], m, n, c;
    int i, j, k;
    j = k = 0;
    printf("\nHow many elements you wanna insert in first array : ");
    scanf("%d", &m);
    printf("Enter %d integers in to first array :\n", m);
    for (c = 0; c < m; c++)
    {   
        scanf("%d", &arr1[c]);      
    }
    printf("\nHow many elements you wanna insert in second array : ");
    scanf("%d", &n);
    printf("Enter %d integers in to second array :\n", n);
    for (c = 0; c < n; c++)
    {   
        scanf("%d", &arr2[c]);   
    }
    for (i = 0; i < m + n;)
    {
        if (j < m && k < n)
        {
            if (arr1[j] < arr2[k])
            {
                sorted[i] = arr1[j];
                j++;
            }
            else
            {
                sorted[i] = arr2[k];
                k++;
            }
            i++;
        }
        else if (j == m)
        {
            for (; i < m + n;)
            {
                sorted[i] = arr2[k];
                k++;
                i++;
            }
        }

        else
        {
            for (; i < m + n;)
            {
                sorted[i] = arr1[j];
                j++;
                i++;
            }
        }
    }
    printf("\nThe elements of merged array are :\n");
    for (c = 0; c < m + n; c++)
    {   
        printf("%d\t", sorted[c]);   
    }
    printf("\n= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =\n\n");
    return 0;
}

Output:

= = = = = = = = = Merge the elements of two array = = = = = = = = =

How many elements you wanna insert in first array : 3
Enter 3 integers in to first array :
2
4
8

How many elements you wanna insert in second array : 4
Enter 4 integers in to second array :
1
4
6
9

The elements of merged array are :
1    2    4    4    6    8    9   
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

C Program to sort an integer array in ascending order.

/*=================================================================================
 **
 **  File Name     : sortArray.c
 **  Creation Date : Mon 15 Feb 2016 04:43:08 AM IST
 **  Last Modified : Mon 15 Feb 2016 05:06:09 AM IST
 **  Compoler      : gcc
 **  Author        : Manoj Kumar Patra, manojpatra.in@gmail.com
 **  Organization  : SCIS, University of Hyderabad, India.
 **
 **===============================================================================*/
#include <stdio.h>
int main()
{
    printf("\n= = = = = Sort the Array elements in ascending order = = = = =\n");
    int i, j, a, n, arr[30];
    printf("\nHow many number you want to sort : ");
    scanf("%d", &n);
    printf("Enter the numbers in to the array :\n");
    for (i = 0; i < n; ++i)
    {
        scanf("%d", &arr[i]);
    }
    printf("The elements of the array are : \n");
    for (i = 0; i < n; ++i)
    {
        printf("%d\t", arr[i]);
    }
    for (i = 0; i < n; ++i)
    {
        for (j = i + 1; j < n; ++j)
        {
            if (arr[i] > arr[j])
            {
                a =  arr[i];
                arr[i] = arr[j];
                arr[j] = a;
            }
        }
    }
    printf("\nThe elements of the array after sorting :\n");
    for (i = 0; i < n; ++i)
    {
        printf("%d\t", arr[i]);
    }
    printf("\n\n= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =\n\n");
}

Output:

= = = = = Sort the Array elements in ascending order = = = = =

How many number you want to sort : 10
Enter the numbers in to the array :
5
3
6
4
8
1
10
2
9
7
The elements of the array are :
5    3    6    4    8    1    10    2    9    7   
The elements of the array after sorting :
1    2    3    4    5    6    7    8    9    10   

= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

C program to print pattern-b

/*=================================================================================
**
**  File Name     : printPattern_b.c
**  Creation Date : Wed 10 Feb 2016 08:04:44 PM IST
**  Last Modified : Mon 15 Feb 2016 04:32:19 AM IST
**  Compoler      : gcc
**  Author        : Manoj Kumar Patra, manojpatra.in@gmail.com
**  Organization  : SCIS, University of Hyderabad, India.
**
**===============================================================================*/

#include<stdio.h>
int main()
{
    printf("\n= = = = = = = = = = Print Pattern = = = = = = = = = =\n");
    int n, i, j, count, item=1;
    printf("\nEnter the value of 'n' : ");
    scanf("%d",&n);
    count=n;
    j=n;
    printf("\n");
    for(i=0; i<j; i++)
    {
        while(count!=0)
        {
            printf("%d\t",item);
            count--;
        }
        printf("\n\n");
        n=n-1;
        count=n;
        item++;
    }
    printf("= = = = = = = = = = = = = = = = = = = = = = = = = = =\n");
    printf("\n");
}

Output:

= = = = = = = = = = Print Pattern = = = = = = = = = =

Enter the value of 'n' : 5

1    1    1    1    1   

2    2    2    2   

3    3    3   

4    4   

5   

= = = = = = = = = = = = = = = = = = = = = = = = = = =

C program to print pattern-a

/*=================================================================================
**
**  File Name     : printPattern_a.c
**  Creation Date : Wed 10 Feb 2016 08:04:44 PM IST
**  Last Modified : Mon 15 Feb 2016 04:25:51 AM IST
**  Compoler      : gcc
**  Author        : Manoj Kumar Patra, manojpatra.in@gmail.com
**  Organization  : SCIS, University of Hyderabad, India.
**
**===============================================================================*/

#include<stdio.h>
int main()
{
    printf("\n= = = = = = = = = = Print Pattern = = = = = = = = = =\n");
    int n, i, count, item=1;
    printf("\nEnter the value of n : ");
    scanf("%d",&n);
    printf("\n");
    for(i=0; i<n; i++)
    {
        count=i+1;
        while(count!=0)
        {
            printf("%d\t",item);
            count--;
            item++;
        }
        printf("\n\n");
        item=1;
    }
    printf("= = = = = = = = = = = = = = = = = = = = = = = = = = =\n");
    printf("\n");
}

Output:

= = = = = = = = = = Print Pattern = = = = = = = = = =

Enter the value of n : 5

1   

1    2   

1    2    3   

1    2    3    4   

1    2    3    4    5   

= = = = = = = = = = = = = = = = = = = = = = = = = = =

C Program to calculate gross salary

/*=================================================================================
**
**  File Name     : grossSalary.c
**  Creation Date : Mon 15 Feb 2016 03:33:41 AM IST
**  Last Modified : Mon 15 Feb 2016 04:02:41 AM IST
**  Compoler      : gcc
**  Author        : Manoj Kumar Patra, manojpatra.in@gmail.com
**  Organization  : SCIS, University of Hyderabad, India.
**
**===============================================================================*/

#include<stdio.h>
int main()
{
    printf("\n= = = = = = = = = = Calculation of Gross Salary = = = = = = = = = =\n");
    int bs;
    float hra, da, gs;
    printf("\nEnter the Basic Salary(must be a +ve integer): ");
    scanf("%d",&bs);
    if(bs >=1 && bs<=1000)
    {
        hra = (10*bs)/100;
        da = (50*bs)/100;
        printf("\nThe House Rent Allowance is 10 percent of %d = %f\n",bs,hra);
        printf("\nThe Dearness Allowance is 50 percent of %d = %f\n",bs,da);
    }
    else if(bs >=1001 && bs<=2000)
    {
        hra = (20*bs)/100;
        da = (60*bs)/100;
        printf("\nThe House Rent Allowance is 20 percent of %d = %f\n",bs,hra);
        printf("\nThe Dearness Allowance is 60 percent of %d = %f\n",bs,da);
    }
    else if(bs >=2001 && bs<=3000)
    {
        hra = (25*bs)/100;
        da = (70*bs)/100;
        printf("\nThe House Rent Allowance is 25 percent of %d = %f\n",bs,hra);
        printf("\nThe Dearness Allowance is 70 percent of %d = %f\n",bs,da);
    }
    else
    {
        hra = (30*bs)/100;
        da = (80*bs)/100;
        printf("\nThe House Rent Allowance is 30 percent of %d = %f\n",bs,hra);
        printf("\nThe Dearness Allowance is 80 percent of %d = %f\n",bs,da);
    }
    gs = bs + hra + da;
    printf("\nThe Gross Salary of %d is: %f\n",bs,gs);
    printf("\n= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =\n\n");
}

Output:

= = = = = = = = = = Calculation of Gross Salary = = = = = = = = = =

Enter the Basic Salary(must be a +ve integer): 13400

The House Rent Allowance is 30 percent of 13400 = 4020.000000

The Dearness Allowance is 80 percent of 13400 = 10720.000000

The Gross Salary of 13400 is: 28140.000000

= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

Sunday, February 14, 2016

C Program to calculate the Simple Interest

/*==========================================================================================
**
**  File Name     : simpleInterest.c
**  Creation Date : Mon 15 Feb 2016 03:04:48 AM IST
**  Last Modified : Mon 15 Feb 2016 03:26:28 AM IST
**  Compoler      : gcc
**  Author        : Manoj Kumar Patra, manojpatra.in@gmail.com
**  Organization  : SCIS, University of Hyderabad, India.
**
**=========================================================================================*/

#include<stdio.h>
int main()
{
    float pa, rt, si, total;
    int t;
    printf("\n= = = = = = = = =  = Simple Interest Calculation = = = = = = = = = =");
    printf("\nEnter the principal amount: ");
    scanf("%f",&pa);
    printf("\nEnter the rate of interest: ");
    scanf("%f",&rt);
    printf("\nEnter the duration of time in Year: ");
    scanf("%d",&t);
    si = (pa * t * rt)/100;
    total = pa + si;
    printf("\nThe Interest Amount of Rs %f for %d years is: %f\n",pa,t,si);
    printf("\nThe Total Amount is %f + %f = %f",pa,si,total);
    printf("\n= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =\n\n");
}

Output:

= = = = = = = = =  = Simple Interest Calculation = = = = = = = = = =
Enter the principal amount: 500

Enter the rate of interest: 13.5

Enter the duration of time in Year: 5

The Interest Amount of Rs 500.000000 for 5 years is: 337.500000

The Total Amount is 500.000000 + 337.500000 = 837.500000
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =