1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Sedaia [141]
3 years ago
6

Write a bash script HW4p2.sh to print out the list of numbers between 0 to 100 (including 0 and 100) that are divisible by both

3 and 5. You must create a bash function inside the script to check the divisibility by 3 and 5.
Computers and Technology
1 answer:
ratelena [41]3 years ago
8 0

Answer:

#!/bin/bash

function number_div( ) {

   for i in {0. .100};

   do

   if (( $i % 3 == 0 ))

   then

   echo $i

   elif (( $i % 5 == 0 ))

   then

   echo $i

   else

   echo "Number not divisible by 3 and 5"

   fi;

   done

}

number_div( )

Explanation:

The bash script is saved as "HW4p2.sh" and executed as "./HW4p2.sh". This code would print all and only numbers divisible by 3 or 5.

You might be interested in
Find the number of times a value appears in a list, and create a new list that contains the index positions where the value occu
Maru [420]

Answer:

Program :

list_1=[]#take the empty list.

size=int(input("Enter the size of the list: "))#take the size of the list from the user

for x in range(size): #for loop which insert the elemnt on the list.

   list_1.append(int(input("Enter the "+str(x+1)+" element of the list: ")))#take the user input and insert the element.

element=int(input("Enter the element to be searched: "))#it take the elemnt to search.

loc=1#intialize the location value.

count=0

for x in list_1:#for loop to check the element.

   if(x==element): #check the element.

       print(loc,end=", ")#print the location of the element.

       count=count+1

   loc=loc+1

if(count==0):

   print("The element is not present on the list")#print when elemnt are not present.

Output:

  • If the user input 5 for the size and 1,2,3,4,5 for the list and 5 for the element, then it will print 5.

Explanation:

  • The above code is in python language which is used to take the size for the list, then take the value to add on the list.
  • Then the element is entered from the user to search on the list.
  • Then the element is searched on the list with the help of for loop.
  • It prints the location when the element is matched.

3 0
3 years ago
Select the correct answer.
Gnom [1K]

Answer:

CSS, HTML & JavaScript.

Explanation:

The first Murray will need to learn will be HTML for the site and then CSS for the design of the site.

Then he needs JavaScript to allow him make his showcase his pictures.

4 0
4 years ago
What decimal value does the 8-bit binary number 10011110 have if it is on a computer using signed-magnitude representation?
Ymorist [56]

1 0 0 1 1 1 1 0

0 * 2^{0} + 1 * 2^{1} + 1 * 2^{2} + 1 * 2^{3} + 1 * 2^{4}  + 0 * 2^{5} + 0 * 2^{6} = 30

The sign digit is a 1, so the entire number is negative, which gives -30.

3 0
4 years ago
def c_to_f(): # FIXME return # FIXME: Finish temp_c = float(input('Enter temperature in Celsius: ')) temp_f = None # FIXME: Call
Agata [3.3K]

Answer:

  1. def c_to_f(celsius):  
  2.    return celsius * 9/5 + 32
  3. temp_c = float(input('Enter temperature in Celsius: '))  
  4. temp_f = None  
  5. temp_f = c_to_f(temp_c)  
  6. print('Fahrenheit:' , temp_f)

Explanation:

The first piece of code we can fill in is the formula to convert Celsius to Fahrenheit and return it as function output (Line 2).

The second fill-up code is to call the function c_to_f and pass temp_c as argument (Line 7). The temp_c will be processed in the function and an equivalent Fahrenheit value will be returned from the function and assigned it to temp_f.

4 0
4 years ago
Write an algorithm
liq [111]

Answer:Pseudocode & Algorithm Example 1: Write an algorithm to determine a student's final ... Pseudocode & Algorithm Pseudocode: Input a set of 4 marks Calculate their average by ... Information system flowcharts show how data flows from source documents ... Different symbols are used to draw each type of flowchart.

Explanation:

7 0
3 years ago
Other questions:
  • The domain in an email message tells you what?
    11·1 answer
  • Consider the following two tables where EmployeeNum is primary key in both tables. What is the result of combining the two table
    5·1 answer
  • Describe the difference between cellular, wi-fi and wired networks.
    8·1 answer
  • A Windows user right-clicks on his desktop. What is he planning to do?
    10·1 answer
  • PLS HELP IMEDIATELY!!!!!
    15·2 answers
  • How many bit make a byte .​
    12·2 answers
  • Spam is _____.
    6·2 answers
  • Five advantages of Internet​
    12·1 answer
  • A ____________ is a set of commands which can be run by calling it by name.
    15·1 answer
  • Which CPT icon should be considered when entering CPT codes into a spreadsheet for numerical sorting
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!