# Convert the square inch to square yard

The conversion of units is a common task in programming, especially when dealing with measurements. In this article, we will focus on converting square inches to square yards using a simple program. We'll walk through the problem statement, explain the solution with suitable examples, provide the algorithm, and analyze the time complexity of the code.

## Problem Statement

The problem is to convert a given area in square inches to the corresponding area in square yards. This involves taking a value in square inches, dividing it by the conversion factor, and obtaining the equivalent area in square yards. The formula for conversion is:

`Square Yards = Square Inches / 1296`

## Example

Let's say we have an area of 2592 square inches. To convert this to square yards, we would use the formula:

`Square Yards = 2592 / 1296 = 2`

So, 2592 square inches is equal to 2 square yards.

## Idea to Solve the Problem

To solve this problem, we need to write a C program that takes a value in square inches as input, performs the conversion using the formula, and then outputs the corresponding value in square yards.

## Pseudocode

Here's the pseudocode for the solution:

```
function square_inch_to_square_yard(square_inch)
square_yard = square_inch / 1296
output "Square inch:", square_inch, "Square yard:", square_yard
end function
main
square_inch_to_square_yard(1)
square_inch_to_square_yard(2021)
square_inch_to_square_yard(1500.6)
end main
```

## Algorithm Explanation

- The
`square_inch_to_square_yard`

function takes a single parameter,`square_inch`

, which represents the area in square inches to be converted. - Inside the function, the square inch value is divided by 1296 to calculate the equivalent area in square yards.
- The calculated values of square inch and square yard are then printed as output, along with appropriate labels.
- In the
`main`

function, the`square_inch_to_square_yard`

function is called three times with different test values to demonstrate the conversion.

## Program Solution

```
//C Program
//Convert the square inch to square yard
#include <stdio.h>
//Find the square inch of given square yard
void square_inch_to_square_yard(double square_inch)
{
// Calculate square yard
// Formula : (Square inch / 1296)
double square_yard = (square_inch / 1296);
printf("Square inch : %lf, Square yard : %lf\n", square_inch, square_yard);
}
int main()
{
//Simple test
square_inch_to_square_yard(1);
square_inch_to_square_yard(2021);
square_inch_to_square_yard(1500.6);
return 0;
}
```

#### Output

```
Square inch : 1.000000, Square yard : 0.000772
Square inch : 2021.000000, Square yard : 1.559414
Square inch : 1500.600000, Square yard : 1.157870
```

```
/*
Java program
Convert the square inch to square yard
*/
class MyMath
{
//Find the square inch of given square yard
public void square_inch_to_square_yard(double square_inch)
{
// Calculate square yard
// Formula : (Square inch / 1296)
double square_yard = (square_inch / 1296);
System.out.print("Square inch : " + square_inch + " , Square yard : " + square_yard + "\n");
}
public static void main(String[] args)
{
MyMath obj = new MyMath();
//Simple test
obj.square_inch_to_square_yard(1);
obj.square_inch_to_square_yard(2021);
obj.square_inch_to_square_yard(1500.6);
}
}
```

#### Output

```
Square inch : 1.0 , Square yard : 7.716049382716049E-4
Square inch : 2021.0 , Square yard : 1.5594135802469136
Square inch : 1500.6 , Square yard : 1.1578703703703703
```

```
/*
C++ program
Convert the square inch to square yard
*/
#include<iostream>
using namespace std;
class MyMath
{
public:
//Find the square inch of given square yard
void square_inch_to_square_yard(double square_inch)
{
// Calculate square yard
// Formula : (Square inch / 1296)
double square_yard = (square_inch / 1296);
cout << "Square inch : " << square_inch << " , Square yard : " << square_yard << "\n";
}
};
int main()
{
MyMath obj;
//Simple test
obj.square_inch_to_square_yard(1);
obj.square_inch_to_square_yard(2021);
obj.square_inch_to_square_yard(1500.6);
return 0;
}
```

#### Output

```
Square inch : 1 , Square yard : 0.000771605
Square inch : 2021 , Square yard : 1.55941
Square inch : 1500.6 , Square yard : 1.15787
```

```
/*
C# program
Convert the square inch to square yard
*/
using System;
class MyMath
{
//Find the square inch of given square yard
public void square_inch_to_square_yard(double square_inch)
{
// Calculate square yard
// Formula : (Square inch / 1296)
double square_yard = (square_inch / 1296);
Console.Write("Square inch : " + square_inch + " , Square yard : " + square_yard + "\n");
}
public static void Main(String[] args)
{
MyMath obj = new MyMath();
//Simple test
obj.square_inch_to_square_yard(1);
obj.square_inch_to_square_yard(2021);
obj.square_inch_to_square_yard(1500.6);
}
}
```

#### Output

```
Square inch : 1 , Square yard : 0.000771604938271605
Square inch : 2021 , Square yard : 1.55941358024691
Square inch : 1500.6 , Square yard : 1.15787037037037
```

```
<?php
/*
Php program
Convert the square inch to square yard
*/
class MyMath
{
//Find the square inch of given square yard
public function square_inch_to_square_yard($square_inch)
{
// Calculate square yard
// Formula : (Square inch / 1296)
$square_yard = ($square_inch / 1296);
echo "Square inch : ". $square_inch ." , Square yard : ". $square_yard ."\n";
}
}
function main()
{
$obj = new MyMath();
//Simple test
$obj->square_inch_to_square_yard(1);
$obj->square_inch_to_square_yard(2021);
$obj->square_inch_to_square_yard(1500.6);
}
main();
```

#### Output

```
Square inch : 1 , Square yard : 0.0007716049382716
Square inch : 2021 , Square yard : 1.5594135802469
Square inch : 1500.6 , Square yard : 1.1578703703704
```

```
/*
Node Js program
Convert the square inch to square yard
*/
class MyMath
{
//Find the square inch of given square yard
square_inch_to_square_yard(square_inch)
{
// Calculate square yard
// Formula : (Square inch / 1296)
var square_yard = (square_inch / 1296);
process.stdout.write("Square inch : " + square_inch + " , Square yard : " + square_yard + "\n");
}
}
function main()
{
var obj = new MyMath();
//Simple test
obj.square_inch_to_square_yard(1);
obj.square_inch_to_square_yard(2021);
obj.square_inch_to_square_yard(1500.6);
}
main();
```

#### Output

```
Square inch : 1 , Square yard : 0.0007716049382716049
Square inch : 2021 , Square yard : 1.5594135802469136
Square inch : 1500.6 , Square yard : 1.1578703703703703
```

```
# Python 3 program
# Convert the square inch to square yard
class MyMath :
# Find the square inch of given square yard
def square_inch_to_square_yard(self, square_inch) :
# Calculate square yard
# Formula : (Square inch / 1296)
square_yard = (square_inch / 1296)
print("Square inch : ", square_inch ," , Square yard : ", square_yard ,"\n", end = "")
def main() :
obj = MyMath()
# Simple test
obj.square_inch_to_square_yard(1)
obj.square_inch_to_square_yard(2021)
obj.square_inch_to_square_yard(1500.6)
if __name__ == "__main__": main()
```

#### Output

```
Square inch : 1 , Square yard : 0.0007716049382716049
Square inch : 2021 , Square yard : 1.5594135802469136
Square inch : 1500.6 , Square yard : 1.1578703703703703
```

```
# Ruby program
# Convert the square inch to square yard
class MyMath
# Find the square inch of given square yard
def square_inch_to_square_yard(square_inch)
# Calculate square yard
# Formula : (Square inch / 1296)
square_yard = (square_inch / 1296.0)
print("Square inch : ", square_inch ," , Square yard : ", square_yard ,"\n")
end
end
def main()
obj = MyMath.new()
# Simple test
obj.square_inch_to_square_yard(1)
obj.square_inch_to_square_yard(2021)
obj.square_inch_to_square_yard(1500.6)
end
main()
```

#### Output

```
Square inch : 1 , Square yard : 0.0007716049382716049
Square inch : 2021 , Square yard : 1.5594135802469136
Square inch : 1500.6 , Square yard : 1.1578703703703703
```

```
/*
Scala program
Convert the square inch to square yard
*/
class MyMath
{
//Find the square inch of given square yard
def square_inch_to_square_yard(square_inch: Double): Unit = {
// Calculate square yard
// Formula : (Square inch / 1296)
var square_yard: Double = (square_inch / 1296);
print("Square inch : " + square_inch + " , Square yard : " + square_yard + "\n");
}
}
object Main
{
def main(args: Array[String]): Unit = {
var obj: MyMath = new MyMath();
//Simple test
obj.square_inch_to_square_yard(1);
obj.square_inch_to_square_yard(2021);
obj.square_inch_to_square_yard(1500.6);
}
}
```

#### Output

```
Square inch : 1.0 , Square yard : 7.716049382716049E-4
Square inch : 2021.0 , Square yard : 1.5594135802469136
Square inch : 1500.6 , Square yard : 1.1578703703703703
```

```
/*
Swift program
Convert the square inch to square yard
*/
class MyMath
{
//Find the square inch of given square yard
func square_inch_to_square_yard(_ square_inch: Double)
{
// Calculate square yard
// Formula : (Square inch / 1296)
let square_yard: Double = (square_inch / 1296);
print("Square inch : ", square_inch ," , Square yard : ", square_yard ,"\n", terminator: "");
}
}
func main()
{
let obj: MyMath = MyMath();
//Simple test
obj.square_inch_to_square_yard(1);
obj.square_inch_to_square_yard(2021);
obj.square_inch_to_square_yard(1500.6);
}
main();
```

#### Output

```
Square inch : 1.0 , Square yard : 0.000771604938271605
Square inch : 2021.0 , Square yard : 1.55941358024691
Square inch : 1500.6 , Square yard : 1.15787037037037
```

## Time Complexity

The time complexity of the conversion process is constant for each conversion since it only involves simple arithmetic operations (division). Therefore, the time complexity of the code is O(1), which signifies that the execution time remains constant regardless of the input size.

Please share your knowledge to improve code and content standard. Also submit your doubts, and test case. We improve by your feedback. We will try to resolve your query as soon as possible.

## New Comment