Read an amount of water, in quarts, and displays the number of water molecules in that amount. - C Data Type

C examples for Data Type:float

Introduction

The mass of a single molecule of water is about 3.0x10 grams.

A quart of water is about 950 grams.

Demo Code



#include <stdio.h>  

int main(void)  
{  //from w  ww .j ava 2  s  .c o m
    float mass_mol = 3.0e-23;    /* mass of water molecule in grams */  
    float mass_qt = 950;        /* mass of quart of water in grams */  
    float quarts;  
    float molecules;  
      
    printf("Enter the number of quarts of water: ");  
    scanf("%f", &quarts);  
    molecules = quarts * mass_qt / mass_mol;  
    printf("%f quarts of water contain %e molecules.\n", quarts, molecules);  
    return 0;  
}

Result


Related Tutorials