Home » C solved programs » C basic programs

C program to convert feet to inches

In this c program we are going to learn how to convert given feet into inches?

Let’s understand what are feet and inches first...

Word Feet is a plural of foot which is a measurement unit of length and inch is also a measurement of unit length. A foot contains 12 inches.

So the logic to convert feet to inches is quite very simple, we have to just multiply 12 into the given feet (entered through the user) to get the measurement in inches.

In this example, we will read value of feet from the user and displays converted inches to the standard output device.

C program - Convert Feet to Inches

Let’s consider the following example:

#include<stdio.h>

int main()
{
		int feet,inches;
		
		printf("Enter the value of feet: ");
		scanf("%d",&feet);
		
		//converting into inches
		inches=feet*12;
		
		printf("Total inches will be: %d\n",inches);
		return 0;
}

Output

    Enter the value of feet: 15 
    Total inches will be: 180

Using user define function

Here we are going to declare an user define function feet2Inches() this function will take feet as arguments and returns inches value.

#include<stdio.h>

//function feet2Inches
int feet2Inches(int f)
{
	return (f*12);
}

int main()
{
		int feet,inches;
		
		printf("Enter the value of feet: ");
		scanf("%d",&feet);
		
		//converting into inches
		inches=feet2Inches(feet);
		
		printf("Total inches will be: %d\n",inches);
		return 0;
}

Output

    Enter the value of feet: 15 
    Total inches will be: 180






Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.





Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.