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
Whitepunk [10]
2 years ago
15

The following program declares an array of char named as myString There are 6 following cases (a, b, c, d, e, f) to access myStr

ing. Which cases are valid access? If there are any invalid cases, how to correct them? #include using namespace std; int main() { char myString[16]; //a. strcpy_s(myString, "Hello the world"); //b. cout << strlen(myString); //c. myString = "Mary Lane"; //d. cin.getline(myString, 80); //e. cout << myString; //f. myString[6] = 't'; return 0;
Computers and Technology
1 answer:
yuradex [85]2 years ago
3 0

Answer:

See explaination

Explanation:

a.

myString is "Hello the world"

b.

prints "15"

c.

This is invalid.

We have to use strcpy_s to copy strings

FIX:

strcpy_s(s,"Marylane");

d.

reading string upto length 80 from the user and stored it in myString variable

e.

prints the string enetered by user to console

f.

replacing 7th character by 't'

You might be interested in
Happy Valentine's day!!
Lorico [155]
Happy valentine’s u too !!
7 0
2 years ago
Give a big-O estimate for the number additions used in this segment of an algorithm.
rjkz [21]
Big-O notation is a way to describe a function that represents the n amount of times a program/function needs to be executed. 

(I'm assuming that := is a typo and you mean just =, by the way) 

In your case, you have two loops, nested within each other, and both loop to n (inclusive, meaning, that you loop for when i or j is equal to n), and both loops iterate by 1 each loop.

This means that both loops will therefore execute an n amount of times. Now, if the loops were NOT nested, our big-O would be O(2n), because 2 loops would run an n amount of times.

HOWEVER, since the j-loop is nested within i-loop, the j-loop executes every time the i-loop <span>ITERATES. 
</span>
As previously mentioned, for every i-loop, there would be an n amount of executions. So if the i-loop is called an n amount of times by the j loop (which executes n times), the big-O notation would be O(n*n), or O(n^2). 

(tl;dr) In basic, it is O(n^2) because the loops are nested, meaning that the i-loop would be called n times, and for each iteration, it would call the j-loop n times, resulting in n*n runs.

A way to verify this is to write and test program the above. I sometimes find it easier to wrap my head around concepts after testing them myself.
3 0
3 years ago
Write a class named GasTank containing: An instance variable named amount of type double, initialized to 0. An instance variable
telo118 [61]

Answer:

The class GasTank is defined below

All the steps are briefed in comments

public class GasTank {

// instance variable initialization

private double amount = 0;

//declaring instance variable capacitance

private double capacity;

//constructor having parameter of type double

public GasTank(double i)

{

capacity = i;

}

// addGas method for increasing gas quantity.

public void addGas(double i)

//quantity of gas increased is added to the existing amount. If it becomes more than total capacity, amount is set to capacity

{ amount += i; if(amount > capacity) amount = capacity; / amount = amount < capacity ? amount+i : capacity;/ }

//useGas method having parameter of type double

public void useGas(double i)

//the parameter given is deducted from 0 and if results less than 0, remains equal to 0

{ amount = amount < 0 ? 0 : amount - i; }

//method isEmpty

public boolean isEmpty()

//Returns true if volume is less than 0.1 else false

{ return amount < 0.1 ? true : false; }

//method isFull

public boolean isFull()

//returns true if the value of amount is greater than  0.1 else false.

{ return amount > (capacity-0.1) ? true : false; }

//method getGasLeve

public double getGasLevel()

//Returns the value of amount instance variable

{ return amount; }

//method fillUp

public double fillUp()

//returns the difference between the capacity and the amount

{ double blah = capacity - amount; amount = capacity; return blah; }

}

5 0
3 years ago
2 steps to electronically reproduce an image
yawa3891 [41]

Answer:

The two steps are: obtaining rights to reproduce the photograph from the copyright owner. The owner can be a photographer, some company or stock house dealing photos. And the requester has to get the rights for all that is in the picture like a celebrity, trademark rights, etc. However, if you sign the enclosed document then you need to take care of the first step only.

Explanation:

Please check the answer.

5 0
2 years ago
Choose the best answer a) Which is NOT a Graphics software​
Alchen [17]

Answer:

Software that people think of as graphics software, but isn't, include programs that don't directly manipulate individual images. Page layout software such as InDesign, QuarkXpress, and Publisher fall into that category. Likewise, presentation software such as PowerPoint or Apple Keynote aren't graphics programs

Explanation:

3 0
2 years ago
Other questions:
  • In Paint, which of the following are ways to use a picture that you have saved on your computer? (Select all that apply.)
    8·1 answer
  • 1.using synonyms can help make ur writing more________
    11·1 answer
  • True or False. When used with the cout object, the endl stream manipulator advances the cursor to the next line on the computer
    6·1 answer
  • A ___ is a node (or a device) that connects two different networks together and allows them to communicate.
    12·1 answer
  • When you're working with a word processing document and you press the del key, what happens?
    6·2 answers
  • Comments should be written in what type of language
    6·1 answer
  • it is used to hold screws, jumpers, fasteners, and other small parts and prevent them from getting mixed together​
    15·2 answers
  • List 5 ways by which Artificial intelligence (AI) can be used to drive our business.​
    14·1 answer
  • What science category includes physics and biology?
    14·1 answer
  • Write a program that produces the following output: CCCCCCCCC ++ ++ CC ++ ++ CC ++++++++++++++ +++++++++++++++ CC ++++++++++++++
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!