This blog is under construction

Sunday, 7 July 2013

C program to convert feet to inches

Write a C program to convert feet to inches.

  #include <stdio.h>

  int main() {
        float feet, inches;

        /* get the number of feet from ther user */
        printf("Enter the number of feet:");
        scanf("%f", &feet);

         * converting feet to inches
         * 1 feet is equal to 12 inches
        inches = feet * 12.0;
        printf("%.2f feet is equal to %.2f inches\n", feet, inches);
        return 0;

  jp@jp-VirtualBox:~/cpgms/lab_pgms/01_cbasics$ ./a.out
  Enter the number of feet:12
  12.00 feet is equal to 144.00 inches

See Also:

No comments:

Post a Comment