Answer:
Explanation:
The code in C++ is written as:
#include <iostream>
using namespace std;
int smallestIndex(int arr[],int size)
{
int min=arr[0],ind=0;
for(int i=0;i<size;i++)
{
if(min>arr[i])
{
min=arr[i];
ind=i; NOTE: ind serves as a variable that is holding the smallest
} element index of array
}
return ind;
}
int main() {
int arr[15];
cout<<"Enter 15 integers: ";
for(int i=0;i<15;i++)
cin>>arr[i];
for(int i=0;i<15;i++)
cout<<arr[i]<<" "<<endl;
int index=smallestIndex(arr,15);
cout<<"The position of the first occurrence of the smallest element in list is: "<<index<<endl;
cout<<"The smallest element in list is: "<<arr[index];
}
OUTPUT:
Enter 15 integers:
4
5
8
4
6
1
2
1
4
5
7
9
5
7
8
4 5 8 4 6 1 2 1 4 5 7 9 5 7 8
The position of the first occurrence for the smallest element in the list is 5
The smallest element in the list is: 1
Answer:
lst = []
n = int(input("Input an array size for you words array: "))
print("Now please enter " + str(n) + " words")
max = 0
min = 1000
index_min = 0
index_max = 0
for i in range(n):
s = input("Input a word: ")
lst.append(s)
if len(s) >= max:
max = len(s)
index_max = i
if len(s) <= min:
min = len(s)
index_min = i
print("The longest word is :" + lst[index_max])
print("The shortest word is :" + lst[index_min])
Explanation:
Create an empty list, lst
Get the size from the user
Create a for loop that iterates "size" times
Inside the loop, get the strings from the user and put them in the lst. Find the longest and shortest strings and their indices using if structure.
When the loop is done, print the longest and shortest
Answer:
B - The user is no longer able to log on to the network
Explanation:
Answer:
B) Choose from a list of values
Explanation:
Answer:
1. Both Steve Jobs and Steve Wozniak raised $1000 by selling personal items, so that they could start Apple.
2. Steve Wozniak worked for Hewlett Packard designing calculators before starting Apple.
4. Steve Jobs never learned to code and primarily focused on design.
Explanation:
I just took the test.