Answer:
function myFunction() {
myNumber = Math.floor(Math.random() * 100) + 1 ;
var values = ["Number is even", "Number is odd"] ;
var stringNum = " ";
if (myNumber % 2 === 0){
stringNum += values[0];
} else {
stringNum += values[1];
document.getElementById("demo").innerHTML = stringNum;
}
Explanation:
The javascript source code is used by the browser to make the web application interactive, making a clickable event for the button to generate an H1 header for the web page.
The myFunction is assigned to an onclick event of a html button tag to display if a random number between 1 and 100 is even or odd.
I've included my code in the picture below. Best of luck.
Answer:
def print_popcorn_time(bag_ounces):
if bag_ounces<3:
print("Too Small")
elif bag_ounces>10:
print("Too Large")
else:
total = 6*bag_ounces
print('{} seconds'.format(total))
Explanation:
Using Python programming language
The function is defined to accept a single parameter
Using a combination of if/elif/else statements, the approprite message is displayed when the function is called
Answer:
C = M0(M1+M2+M3)+M1(M2+M3)+M2M3 is the equation which suits
Explanation:
From the given data we can state that we need to activate only one product i.e 1------>activated 0-------->means inactivated and also only one slot is activated at a time.The resultant will be no data inputs n control bits and 2 to the power n output bits.
Answer:
Step by step explanation along with code and output is provided below
Explanation:
#include<iostream>
using namespace std;
// print_seconds function that takes three input arguments hours, mints, and seconds. There are 60*60=3600 seconds in one hour and 60 seconds in a minute. Total seconds will be addition of these three
void print_seconds(int hours, int mints, int seconds)
{
int total_seconds= hours*3600 + mints*60 + seconds;
cout<<"Total seconds are: "<<total_seconds<<endl;
}
// test code
// user inputs hours, minutes and seconds and can also leave any of them by entering 0 that will not effect the program. Then function print_seconds is called to calculate and print the total seconds.
int main()
{
int h,m,s;
cout<<"enter hours if any or enter 0"<<endl;
cin>>h;
cout<<"enter mints if any or enter 0"<<endl;
cin>>m;
cout<<"enter seconds if any or enter 0"<<endl;
cin>>s;
print_seconds(h,m,s);
return 0;
}
Output:
enter hours if any or enter 0
2
enter mints if any or enter 0
25
enter seconds if any or enter 0
10
Total seconds are: 8710