Popular Posts

Saturday, November 28, 2015

Convert gallon to litter in C language

#include <stdio.h>


void main()
{
    float gallon,litter;

    printf("\n\n");
    printf("\t\tGallon       Litre");
    printf("\n\t\t......       ......");


    for(gallon=1; gallon<=10; gallon++)
    {
       litter = gallon*3.785;
       printf("\n\t\t%5.2f        %5.2f", gallon, litter);
    }
    printf("\n\n");
    return 0;
}

Decimal to Binary in C language

#include <stdio.h>
#include <math.h>

void main()
{
    long int d_n, rem, b_n = 0, base=1;
    printf("Enter a decimal number : ");
    scanf("%ld",&d_n);
    printf("\n\n\nYour entered decimal number is : %ld",d_n);
    while(d_n!=0)
    {
        rem=d_n%2;
        b_n+=rem*base;
        base*=10;
        d_n/=2;
    }

    printf("\nYahoo Your entered decimal number is converted into binary");
    printf("\nAnd the number is : %ld",b_n);

    return 0;
}

Area triangle in C language

#include <stdio.h>

void main()
{
    float a,b,c;
    float p,area,s;

    a=5;
    b=5;
    c=6;

    s =((a+b+c)/2);
    p = (s*(s-a)*(s-b)*(s-c));
    area = pow(p,.5);
    printf("area is %f", area);

}

Addition Subtraction Multiplication Division in C Language

#include <stdio.h>
#include <stdlib.h>

int main()
{
    char latter;
    printf("What operation you want to do?\n\t A)Addition\n\t B)Subtraction\n\t C)Multiplication\n\t D)Division\n\n\nEnter Your Choice: ");
    scanf("%c", &latter);
    float num1, num2;
    printf("\n\tplease enter the first number: ");
    scanf("%f", &num1);
    printf("\n\tplease enter the second number: ");
    scanf("%f", &num2);
    if(latter == 'A' || latter == 'a')
        printf("\n\tthe sum is %.2f", num1+num2);
    else if(latter == 'B' || latter == 'b')
        printf("\n\tthe difference is %.2f", num1-num2);
    else if(latter == 'C' || latter == 'c')
        printf("\n\tthe multiplication is %.2f", num1*num2);
    else if(latter == 'D' || latter == 'd')
        printf("\n\tthe division is %.2f", num1/num2);
    else
        printf("\n\tyou entered a invalid character");

    return 0;
}

Odd Even Number Printing Between Given Range In C language

#include<stdio.h>
#include<conio.h>

void main()
{
    char ch;
    int ran_s,ran_e;
    printf("What do you want to do.......\n\nIf you want to print odd number then type 'o'.....\nElse you want to print even number then type 'e'...\n\nWaiting for your wish: ");
    scanf("%c",&ch);


    printf("\nEnter the start range: ");
    scanf("%d", &ran_s);
    printf("\nEnter the end range: ");
    scanf("%d", &ran_e);


    if(ch=='o' || ch=='O')
    {
        printf("\nThe odd number between your given range : \n---------------------------------------------------\n\n");
        for(;ran_s<=ran_e;ran_s++)
        {
            if(ran_s%2==1)
            {
                printf("\n\t\t%d", ran_s);
            }
        }
    }


        else if(ch=='e' || ch=='E')
    {

        printf("\nThe even number between your given range : \n---------------------------------------------------\n\n");
        for(;ran_s<=ran_e;ran_s++)
        {
            if(ran_s%2==0)
            {
                printf("\n\t\t%d", ran_s);
            }
        }
    }



getch();
}

Matrix Information

#include<stdio.h>
#include<conio.h>

void main()
{
    int row, col,row_t,col_t,sumAvb=0,sumBlw=0;
    printf("Enter Row And Collum :");
    scanf("%d%d", &row, &col);
    col_t=col;
    row_t=row;
    int matrix[row_t][col_t];
    for(row=1;row<=row_t;++row)
    {
        for(col=1;col<=col_t;++col)
        {
            printf("element[%d][%d]",row,col);
            scanf("%d",&matrix[row-1][col-1]);
        }
        printf("\n");
    }
    printf("Your matrix is :\n\n\t\t");
    for(row=0;row<row_t;row++)
    {
        for(col=0;col<col_t;col++)
        {
            printf("%d\t",matrix[row][col]);
        }
        printf("\n\t\t");
    }
    printf("\nDiagonal is: \n\t\t");
    for(row=0;row<row_t;row++)
    {
        for(col=0;col<col_t;col++)
        {
            if(row==col)
            {
                printf("%d\t",matrix[row][col]);
            }
        }
    }
    printf("\nAvove is: \n\t\t");
    for(row=0;row<row_t;row++)
    {
        for(col=0;col<col_t;col++)
        {
            if(row<col)
            {
                printf("%d\t",matrix[row][col]);
                sumAvb+=matrix[row][col];
            }
        }
    }
    printf("\nBelow is : \n\t\t");
    for(row=0;row<row_t;row++)
    {
        for(col=0;col<col_t;col++)
        {
            if(row>col)
            {
                printf("%d\t",matrix[row][col]);
                sumBlw+=matrix[row][col];
            }
        }
    }
    printf("\nSum of avove is = %d\nSum of below is = %d \n\n", sumAvb, sumBlw);
    getch();
}

Prepaid Monthly Calling System

/*Here is a program for a post paid customer .where every call cost is 1.25 tk.its a fully postpaid calling system where customer have a monthly limit but he can use how much he want to use. */

#include<stdio.h>

void main()
{
    float rbill=0,blnc,time,tmp_time=0;
    char ch;
    printf("Enter your monthly postpaid limit in taka: ");
    scanf("%f", &blnc);
    loop:
        {
            do
    {
        printf("\n\n");
        printf("Press for a call...");
        getch();
        printf("\nEnter your call time: ");
        scanf("%f", &tmp_time);
        time+=tmp_time;
        rbill+=(tmp_time*1.25);
        printf("Your total call time: %.2f minute.\nYour total bill: %.2f taka.",time,rbill);
    }while(rbill<blnc);
    printf("\n\nSorry You Have Crossed Your Monthly Limit.\nYou have used %.2f extra balance from your limit\n\n", (rbill-blnc));
    printf("If you still want to call press 'c' or 'C' key or Any key to end : ");
    scanf("%s", &ch);
    if(ch=='c'||ch=='C')
    {
        goto loop;
    }
    else
    {
        printf("Program end.");
    }

        }
}