Answers for "C float division"

C
2

C float division

// By default what '/' is doing is a simple euclidian division
// (The remainder is calculated with modulo '%')
//	Casting both numbers to float will get you a nice decimal

float f = (float)a / (float)b
Posted by: Guest on January-07-2021
0

C program for float division of numbers

#include <stdio.h>

void main() {
    int a;
    float b, c, d;
    a = 750;
    b = a / 350;
    c = 750;
    d = c / 350;
    printf("%.2f %.2f", b, d);
    // output: 2.00 2.14
  
}
Posted by: Guest on July-28-2021

Code answers related to "C"

Browse Popular Code Answers by Language