Answer:
Explanation:
#include<iostream>
#include<ctime>
#include<bits/stdc++.h>
using namespace std;
double calculate(double arr[], int l)
{
double avg=0.0;
int x;
for(x=0;x<l;x++)
{
avg+=arr[x];
}
avg/=l;
return avg;
}
int biggest(int arr[], int n)
{
int x,idx,big=-1;
for(x=0;x<n;x++)
{
if(arr[x]>big)
{
big=arr[x];
idx=x;
}
}
return idx;
}
int main()
{
vector<pair<int,double> >result;
cout<<"Enter 1 for iteration\nEnter 2 for exit\n";
int choice;
cin>>choice;
while(choice!=2)
{
int n,m;
cout<<"Enter N"<<endl;
cin>>n;
cout<<"Enter M"<<endl;
cin>>m;
int c=m;
double running_time[c];
while(c>0)
{
int arr[n];
int x;
for(x=0;x<n;x++)
{
arr[x] = rand();
}
clock_t start = clock();
int pos = biggest(arr,n);
clock_t t_end = clock();
c--;
running_time[c] = 1000.0*(t_end-start)/CLOCKS_PER_SEC;
}
double avg_running_time = calculate(running_time,m);
result.push_back(make_pair(n,avg_running_time));
cout<<"Enter 1 for iteration\nEnter 2 for exit\n";
cin>>choice;
}
for(int x=0;x<result.size();x++)
{
cout<<result[x].first<<" "<<result[x].second<<endl;
}
}
The answer & explanation for this question is given in the attachment below.
<h2>Only when the default parameter are defined in the function</h2>
Explanation:
Answer is same for both the question.
- A default argument or default parameter is assigned an automatic value when the function is invoked.
- So the default value will be assigned during the function definition itself.
- You can find the assignment operator which is being used in the function definition.
- You can overwrite the default values by passing your own value in the calling portion
- The constraint here is that, the default parameter should always be the last parameter of function definition to avoid ambiguity.
Answer:
The correct option is;
Integrated circuit
Explanation:
Following the invention of the transistor, the electrical wiring within an electronic device became known as the major factor contributing to the size of these devices and so in 1958 Jack Kilby and Noyce Fairchild independently developed the Integrated Circuit (IC) model which allowed the integration of the entire circuit onto a piece of solid material, making them smaller, faster, cheaper, more reliable to mass produce, made it possible for the development of smaller computers such as laptops and versions of similar technology, such as mobile phones and tablets due to the ease of standardization of ICs, leading to easier links from design to actual product of small communication devices that rely on ICs.
Answer:
Here is the code for a classic C++ program that does it:
--------------------------------------------------------------------------------
#include <iostream>
using namespace std;
int main()
{
int sum = 0;
int n;
cout << "Input 10 numbers: " << endl;
for (int i = 0; i < 10; i++)
{
cin >> n;
sum += n;
}
cout << "Sum of the numbers: " << sum << endl;
}
--------------------------------------------------------------------------------
Explanation:
I'm assuming you know what "include", "using namespace std" and "int main()" do, so I will skip over those.
First, we declare a variable "sum" and initialize it with 0 so we can add numbers to it later.
Then, we declare a variable "n" that will be set as the input of the user.
The "for-loop" will iterate ( go ) from 0 to 9, and will set the value of "n" as the input that is given -> "cin >> n;". After that, we add the value of "n" to the sum variable.
After "i" reaches 9, it will exit the loop and proceed to printing the sum of the numbers.
Hope it helped!