C Program To Divide Any Number By Another


♣ Try it Out ::
#include<stdio.h>
#include<conio.h>

int main()
{
    // code to divide any integer by another
    int a, b;

    printf("\nEnter two Integers: ");
    scanf("%d %d", &a, &b);

    float div1 = 1.0 * a / b;

    printf("Result1: %d / %d = %.2f\n", a, b, div1);

    // code to divide any floating number by another
    float c, d, div2;

    printf("\nEnter two Floating numbers: ");
    scanf("%f %f", &c, &d);

    div2 = c / d;

    printf("Result2: %.2f / %.2f = %.2f\n", c, d, div2);

    getch();
    return(0);
}

♣ Output ::
Enter two Integers: 5 6
Result1: 5 / 6 = 0.83

Enter two Floating numbers: 5.5 5
Result2: 5.50 / 5.00 = 1.10

♣ Downloads ::

Comments

Popular posts from this blog

C++ :: Topological Sort Algorithm (using DFS)

How to Hack Facebook Account

C++ :: Strongly Connected Components Algorithm (SCC)