Write a shell script to accept length and breadth of rectangle from user. Calculate and display area, perimeter, of entered values using choice entered by user.

1 Answer

Answer :

#!/bin/bash

# GNU bash, version 4.3.46

echo "Enter Length of Rectangle: "

read length

echo "Enter Breadth of Rectangle: "

read breadth

echo "Which operation you want to perform? 1: area 2: perimeter"

read ch

case $ch in

1) res=`echo $length \* $breadth | bc`

;;

2) res=` echo 2 \* $length \* $breadth | bc`

;;

esac

echo "Result is $res"

exit 0

Related questions

Description : Write a shell script to accept a number from user check whether number is even or odd.

Last Answer : 2 8

Description : Write a program to accept marks of four subjects as input from user. Calculate and display total and percentage marks of student. 

Last Answer : #include<stdio.h> #include<conio.h> void main() { float marks[4]; float total=0.0, perc=0.0; int i; clrscr(); for(i=1;i<=4;i++) { printf("Enter marks of ... is :%f",total); perc=total/4; printf("Percentage is %f",perc); getch(); }

Description : If the value of a number (N) is entered through keyboard. Write a program using recursion to calculate and display factorial of number (N). 

Last Answer : #include<stdio.h> #include<conio.h> int factorial(int N); void main() { int N,fact; clrscr(); printf("Enter number:"); scanf("%d",&N); fact=factorial(N); printf( ... N) { if(N==1) return(1); else return(N*factorial(N-1)); }

Description : Calculate the perimeter of a rectangle whose area is 25x2 – 35x + 12. -Maths 9th

Last Answer : Given, Area of rectangle = 25x2 - 35x + 12 We know, area of rectangle = length breadth So, by factoring 25x2 - 35x + 12, the length and breadth can be obtained. 25x2 - 35x + 12 = 25x2 - 15x - 20x + 12 => 25x2 - 35x + ... )] = 2(5x - 3 + 5x - 4) = 2(10x - 7) = 20x - 14 So, the perimeter = 20x - 14

Description : Write a program in C++ to accept a string from a user and display its reverse using pointer.

Last Answer : #include<iostream.h> #include<conio.h> #include<string.h> void main() { char str[20],*ptr; int l; clrscr(); cout<<"\n Enter a string : "; cin>>str; l=strlen(str); ... (l!=0) { ptr--; cout<<*ptr; l--; } getch(); }

Description : Write the coordinates of the vertices of a rectangle whose length and breadth are 5 and 3 units respectively, -Maths 9th

Last Answer : Given, length of a rectangle = 5 units and breadth of a rectangle = 3 units One vertex is at origin i.e., (0, 0) and one of the other vertices lies in III quadrant. So, the length of the rectangle is 5 ... negative,direction of y-axis and then vertex is C(0, -3). The fourth vertex B is (-5, - 3).

Description : Write the coordinates of the vertices of a rectangle whose length and breadth are 5 and 3 units respectively, -Maths 9th

Last Answer : Given, length of a rectangle = 5 units and breadth of a rectangle = 3 units One vertex is at origin i.e., (0, 0) and one of the other vertices lies in III quadrant. So, the length of the rectangle is 5 ... negative,direction of y-axis and then vertex is C(0, -3). The fourth vertex B is (-5, - 3).

Description : Write the coordinates of the vertices of a rectangle whose length and breadth are 6 and 3 units respectively, one vertex at the origin, the longer side lies on the y-axis and one of the vertices lies in the second quadrant. -Maths 9th

Last Answer : Solution :-

Description : Give possible expression for the length and breadth of the rectangle whose area is given by 4a2 +4a - 3. -Maths 9th

Last Answer : Given, area of rectangle = 4a2 + 6a-2a-3 = 4a2 + 4a – 3 [by splitting middle term] = 2a(2a + 3) -1 (2a + 3) = (2a – 1)(2a + 3) Hence, possible length = 2a -1 and breadth = 2a + 3

Description : Give possible expression for the length and breadth of the rectangle whose area is given by 4a2 +4a - 3. -Maths 9th

Last Answer : Given, area of rectangle = 4a2 + 6a-2a-3 = 4a2 + 4a – 3 [by splitting middle term] = 2a(2a + 3) -1 (2a + 3) = (2a – 1)(2a + 3) Hence, possible length = 2a -1 and breadth = 2a + 3

Description : If the length of a rectangle is decreased by 3 units and breadth increased by 4 unit, then the area will increase by 9 sq. units. Represent this situation as a linear equation in two variables. -Maths 9th

Last Answer : Solution :-

Description : A is the area of the rectangle with length l units and breadth b units. Rewrite the formula for area making l as the subject.

Last Answer : A is the area of the rectangle with length l units and breadth b units. Rewrite the formula for area making l as the subject.

Description : Area of a rectangle is equal to the area of circle whose radius is 14 cms. If the breadth of the rectangle is 22 cms. What is its length? a) 27 cms b) 28 cms c) 25 cms. d) 29 cms e) None of these

Last Answer : According to question, l×b = ¶r2 l ×22 = 22/7 ×14 × 14 l = 22/7 ×14 × 14/22 cms = 28 cms. Answer: b)

Description : Two concentric circles have radii of 23 cm and 9 cm. A rectangle has an area equal to the annular space between the above two circles. If the breadth of the rectangle is 22 cm then find its length. 1 : 32 cm 2 : 48 cm 3 : 76 cm 4 : 64 cm 5 : None of these

Last Answer : 4 : 64 cm

Description : When an error of 1%is made in the length and breadth of a rectangle, the percentage error (%) in the area of a rectangle will be (A) 0 (B) 1 (C) 2 (D) 4

Last Answer : Answer: B Suppose length is 10 and bredth is 10 then area is 100, 1 % error then 9.9 *9.9 = 98.01. Hence 2 % error will be there.

Description : Write a C++ program to declare a class ‘circle’ with data members as radius and area. Declare a function getdata to accept radius and putdata to calculate and display area of circle.

Last Answer : #include<iostream.h> #include<conio.h> class circle { float radius,area; public: void getdata() { cout<<"Enter radius:"; cin>>radius; } void putdata() { area=3 ... { circle c; clrscr(); c.getdata(); c.putdata(); getch(); }

Description : What is the work The length of a rectangle is 4 cm more than 3 times the width. The perimeter is 88 cm. What are the dimensions of the rectangle Write a system of equations based on the info?

Last Answer : Let its length be 3x+4 and its width be x Perimeter: 2*(3x+4+x) = 88 Solving the equation x = 10 Therefore: length = 34 cm and width = 10 cm Check: 2*(34+10) = 88 cm

Description : How do i calculate the metres of perimeter for a rectangle with sides 17.5 m by 6.25 m wide?

Last Answer : Need answer

Description : How do i calculate the metres of perimeter for a rectangle with sides 17.5 m long by 3.3 m wide?

Last Answer : Perimeter of rectangle: 17.5+3.3+17.5+3.3 = 41.6 metres

Description : Write a C++ program to declare a class addition with data members as x and y. Initialize values of x and y with constructor. Calculate addition and display it using function ‘display’.

Last Answer : #include<iostream.h> #include<conio.h> class addition { int x,y; public: addition(int,int); void display(); }; addition::addition (int x1,int y1) { x=x1; y=y1; } void addition: ... y); } void main() { addition a(3,4); a.display(); getch(); }

Description : The length of a rectangle is decreasing at a rate of 3 cm/sec and breadth is increasing at a rate of 4 cm/sec. Find the rate of change of its (a) peri

Last Answer : The length of a rectangle is decreasing at a rate of 3 cm/sec and breadth is increasing at a ... breadth of rectangle are 7 cm and 8 cm respectively.

Description : The diagonal of a rectangle is 10 units. The formula to find the diagonal is `d=sqrt(l^(2)+b^(2))`. Where l and b are length and breadth respectively.

Last Answer : The diagonal of a rectangle is 10 units. The formula to find the diagonal is `d=sqrt(l^(2)+b ... breadth respectively. (10+b)(10-b) is equal to______.

Description : How many square tiles of side 9 cm are required to cover a rectangle of length 36 cm and breadth 18 cm exactly without any tiles overlapping?

Last Answer : 8 of them.

Description : How many square tiles of side 9 cm are required to cover a rectangle of length 36 cm and breadth 18 cm exactly without any tiles overlapping?

Last Answer : 8 of them.

Description : Write a program to declare class having data member as hrs, mins, secs. Write constructor to assign values and destructor to destroy values. Accept & display data for one object.

Last Answer : #include<iostream.h> #include<conio.h> class time { private: int hrs, mins,sec; public: time(int h,int m,int s) { hrs=h; mins=m; sec=s; } ~time() { cout<< hours ... } }; void main() { time t(2,43,56); t.display(); getch(); }

Description : Write shell script to find factorial of a number.

Last Answer : i=1 f=1 echo " Enter the number" read n while [ $i -le $n ] do f=`expr $f \* $i` i=`expr $i + 1` done echo FACTORIAL = $f output: Enter the number 5 FACTORIAL=120

Description : Write a program to calculate area of circle and area of rectangle using function overloading. 

Last Answer : #include<iostream.h> #include<conio.h> float area(float a) { return (3.14*a*a); } int area(int p,int q) { return(p*q); } void main() { clrscr(); cout< ... ;<<area(6); cout<<"Area of Rectangle:"<<area(5,6); getch(); }

Description : what- the perimeter of a rectangle is 100 centimeters. The length is twice the width.Which equation could you use to find the width of the rectangle in centimeters?

Last Answer : 2(2x) +2x = 100

Description : What is the perimeter in feet of a rectangle with length 5 feet and width 3 feet?

Last Answer : 15 feet

Description : What if the width of a rectangle is 23 centimeters. If the perimeter of the rectangle is 104 centimeters what is the length?

Last Answer : Another Answer:The length of the rectangle is 29 cm because 2*(29+23) = 104 cm which is the perimeter

Description : What is the width of a rectangle who has 222 millimeters as the perimeter and a length of 60 millimeters?

Last Answer : ForP = perimeterL = lengthW = width2L + 2W = PFor the given information this means2x60 + 2W = 222120 + 2W = 2222W = 222W = 51So the Width would be 51 millimeters

Description : Define a class circle having data members pi and radius. Initialize and display values of data members also calculate area of circle and display it.

Last Answer : class abc {  float pi,radius; abc(float p, float r) { pi=p; radius=r; } void area() { float ar=pi*radius*radius; System.out.println("Area="+ar); } void display() { System.out.println("Pi="+pi ... void main(String args[]) { abc a=new abc(3.14f,5.0f); a.display(); a.area(); } }

Description : Write the coordinates of the vertices of a rectangle whose lenght and breadth are 7 and 4 units respectively,one vertex atthe the origin,the longer side lies on the x-axis and one of the vertices lies in the third quadrant. -Maths 9th

Last Answer : Solution :-

Description : If a rectangle and a parallelogram are equal in area and have the same base and are situated on the same side, and the ratio of the perimeter -Maths 9th

Last Answer : answer:

Description : If you have a rectangle whose Perimeter equals 60 and the Area equals 200 what are the lengths of the four sides?

Last Answer : The rectangle must have sides with lengths of 20, 20, 10, and 10.20+20+10+10 = 60 (perimeter)20*10 = 200 (area)

Description : What is the area of a rectangle if the perimeter is 24 units?

Last Answer : Need answer

Description : What is the area of a 24 unit perimeter of a rectangle?

Last Answer : 28 units

Description : Write a program to accept a string as input from user and determine its length. [Don’t use built in library function strlen()]

Last Answer : #include #include void main(){ char str[50]; int i, len=0; clrscr(); printf("Enter a string"); scanf("%s",&str); for(i=0; str[i]!='\0'; i++){ len++; } printf("The length of string is %d",len); getch(); }

Description : The output unit coverts the data entered by the user into computer understandable form. a) True b) False

Last Answer : Answer: b Explanation: The Output unit is responsible for converting the computer obtained data into user understandable format. The Input Unit is responsible for converting the data in computer understandable format

Description : Which file is used to store the user entered password? A. .exe B. .txt C. .iso D. .asm

Last Answer : D. .asm

Description : Write a C++ program to declare a structure employee with members as empid and empname. Accept and display data for one employee using structure variable. 

Last Answer : #include<iostream.h> #include<conio.h> struct employee  { int empid; char empname[10];  }; void main()  { employee e; clrscr(); cout<<"\nEnter employee id ... empid; cout<<"\nThe Employee Name is "<<e.empname; getch();  }

Description : Write a program to declare a class ‘book’ containing data members as ‘title’, ‘author-name’, ‘publication’, ‘price’. Accept and display the information for one object using pointer to that object.

Last Answer : #include<iostream.h> #include<conio.h> class book { char author_name[20]; char title[20]; char publication[20]; float price; public: void Accept(); void Display(); }; void ... title \t author_name \t publication \t price\n ; p-> Display(); getch(); }

Description : Write a program to input name and salary of employee and throw user defined exception if entered salary is negative. 

Last Answer : import java.io.*; class NegativeSalaryException extends Exception { public NegativeSalaryException (String str) { super(str); } } public class S1 { public static void main(String[] args) ...  catch (NegativeSalaryException a) {  System.out.println(a);  } } }

Description : Write a program to accept two numbers from user and perform addition, subtraction, multiplication and division operations using pointer.

Last Answer : #include #include void main() { int no1,no2,*ptr1,*ptr2,result; clrscr(); printf("Enter no1:"); scanf("%d",&no1); printf("\nEnter no2:"); scanf("%d",&no2); ptr1=&no1; ptr2=&no2; ... "\n Multiplication=%d",result); result=*ptr1/(*ptr2); printf("\n Division=%d",result); getch(); }

Description : Write an algorithm to calculate the area of a circle and display the result . Use the formulae A=¶r where ¶ is equal to 3.1416?

Last Answer : 10001/999900

Description : what- based on the given information, which conjecture is invalidGiven: A rectangle has a perimeter of 24 inches.?

Last Answer : The rectangle has a length of 12.

Description : What is the formula for determining the perimeter of a rectangle ?

Last Answer : Formula 2 for determining the perimeter of a rectangle (length + width)

Description : If BD16.5 and CE4.5 what is the perimeter of the rectangle?

Last Answer : Perimeter of rectangle: 16.5+4.5+16.5+4.5 = 42 units

Description : If 15.6 and CE 4.5 what is the perimeter of the rectangle?

Last Answer : If the given dimensions are the length and width of a rectanglethen its perimeter is 15.6+4.5+15.6+4.5 = 40.2

Description : If a rectangle measure 15 inches by 1 34 feet what is the perimeter in yards?

Last Answer : 1.72666 yards.