Answer:
JavaScript code is given below
Explanation:
function calcWordFrequencies() {
var words = prompt("Enter the sentence below").split(" ");
var unique_words = [], freqencies = [], count = 0;
for (var i = 0; i < words.length; i++) {
var found = false;
for (var j = 0; j < count; j++) {
if (words[i] === unique_words[j]) {
freqencies[j] = freqencies[j] + 1;
found = true;
}
}
if (!found) {
unique_words[count] = words[i];
freqencies[count] = 1;
count++;
}
}
for (var i = 0; i < words.length; i++) {
var result = 0;
for (var j = 0; j < count; j++) {
if (words[i] === unique_words[j]) {
result = freqencies[j];
break;
}
}
console.log(words[i] + " " + result);
}
}
5 dequeue operations
6 enqueue operations
10 dequeue operations
8 enqueue operations
2 dequeue operations
3 enqueue operations
Last = 10
Answer:
10
Explanation:
An enqueue operation is a function that adds an element(value) to a queue array. A dequeue operations removes an element from a queue array. Queue arrays follow a first-in-first-out approach, so elements that are first stored in the queue are removed/accessed first(enqueue operations add elements at the rear of the queue array).
The following operations leave 10 elements in the queue of array size 12 after its done:
10 enqueue operations= adds 10 elements
5 dequeue operations= removes 5 elements( 5 elements left in queue)
6 enqueue operations= adds 6 elements(11 elements in queue)
10 dequeue operations= removes 10 elements(1 element left in queue)
8 enqueue operations= adds 8 elements(9 elements in queue)
2 dequeue operations= removes 2 elements(7 elements left in queue)
3 enqueue operations= adds 3 elements(10 elements in queue)
Therefore there are 10 elements in the queue after enqueue and dequeue operations.
class
object
abstract class
Answer:
Operation the correct answer for the given question.
Explanation:
An operation is a template that is used as a template parameter .An operation defined the services and behaviors of the class .The operation is directly invoked on instance .
Attribute define the property of an entity it is not defined the services and behaviors of the class. so this option is incorrect.
Class is the class of variable of method it is not defined the services and behaviors of the class so this option is incorrect.
Object are the rub time entity .object are used access the property of a class it is not defined the services and behaviors of the class so this option is incorrect.
Abstract class is the class which have not full implementation of all the method .it is not defined the services and behaviors of the class so this option is incorrect.
So the correct answer is operation.
Answer:
Each array position holds the position from which the information is going to be retrieved. After the code is run, each position will have the information retrieved from that position.
Explanation:
The best way to solve this problem is working as if we had a very small array. Then we can generalize for the large array.
For example
int a[3];
a[0] = 1; a[1] = 2; a[2] = 0;
for(i = 0; i < 3; i++)
a[i] = a[a[i]];
When i = 0, we have:
a[i] = a[a[i]] = a[a[0]] = a[1] = 2;
When i = 1, we have
a[i] = a[a[i]] = a[a[1]] = a[2] = 0;
When i = 2, we have
a[i] = a[a[i]] = a[a[2]] = a[0] = 1;
Basically, in our small example, each array position holds the index from which we are going to retrieve the information. The same is going to happen in the array of length 99. After the code is run, each position will have the information retrieved from that position
(ii). the circumference of a circle.
Note:
(1). all the programs must allow the user to make his input .
(2).both programs must have both comment using the single line comment or the multiple line comment to give description to both programs.
Answer:
Perimeter:
{ \tt{perimeter = 2(l + w)}}
Circumference:
{ \tt{circumference = 2\pi \: r}}
Justinputthecodesinthenotepad
Answer:
See Explaination
Explanation:
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
float input1, input2, input3;
float sum=0.0, avg, l;
cout<<"enter the value for input1: ";
cin>>input1;
cout<<"enter the value for input2: ";
cin>>input2;
cout<<"enter the value for input3: ";
cin>>input3;
sum=input1+input2+input3;
cout<<"sum of three numbers: "<<sum<<endl;
avg=sum/3;
cout<<"average of three numbers: "<<avg<<endl;
l=log2(input1);
cout<<"log2 value of input1 number: "<<l;
return 0;
}
output:
enter the value for input1: 4
enter the value for input2: 5
enter the value for input3: 6
sum of three numbers: 15
average of three numbers: 5
log2 value of input1 number: 2
b. data
c. label
d. legend