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
Pachacha [2.7K]
3 years ago
8

The C programming language distinguishes character constants from string constants by using single quotation marks for character

s and double quotation marks for strings. Thus, 'c' is the character c, while "c" is a string of length 1 consisting of the single character c.
1. Why do you think this distinction is made? Is it useful?
Computers and Technology
1 answer:
ad-work [718]3 years ago
7 0

Answer:

The C programming language distinguishes character constants from string constants by

using single quotation marks for characters and double quotation marks for strings. Thus,

'c' is the character c, while "c" is a string of length 1 consisting of the single character c.

Why do you think this distinction is made? Is it useful?

(b) Python, on the other hand, uses double quotation marks for both characters and strings

(thus, "c" is either a character or string, depending on context). Discuss the advantages and

disadvantages of these two approaches.

6.3 Discuss the pros and cons of ignoring or requiring “white space” (i.e., blanks, end-of-lines, and

tabs) when recognizing tokens.

6.4 Many programming languages (like C) do not allow nested comments. Why is this requirement

made? Modula-2 and a few other languages do allow nested comments. Why is this useful?

6.5 (a) Describe the strings that are represented by the regular expression:

[0-9]+((E|e)(\+|\-)?[0-9]+)?

(b) Write a regular expression for C identifiers consisting of letters, digits, and the underscore

character ‘_’, and starting with a letter or underscore.

Explanation:

You might be interested in
In a List of Positive Integers, Set MINIMUM to 1. For each number X in the list L, compare it to MINIMUM. If X is smaller, set M
Dvinal [7]

Answer:

The answer to this question is given below in the explanation section.

Explanation:

The given problem scenario is:

In a List of Positive Integers, Set MINIMUM to 1. For each number X in the list L, compare it to MINIMUM. If X is smaller, set MINIMUM to X.

The answer to question A is: this algorithm will not run because:

If you a list of a positive number and you have already set it MINIMUM to 1, the comparison result with MINIMUM will not obtain. For example, lets suppose a list of numbers L. L={1,2,3,1,1,5,4,3,2}. You have already set the Minimum to 1. When you compare each number X in the list, if X >MINIMUM, then set MINIMUM to X.  

This will not work, because there are positive numbers in the list and the minimum positive number is 1. So the algorithm, will not execute the if-part.

In short, the pseudo-code of this problem is given below:

<em>L={list of positive number e.g. 1,2,3,.......Xn}</em>

<em>MINIMUM=1</em>

<em>foreach ( X in L)</em>

<em>{</em>

<em>(if X<MINIMUM)</em>

<em>    { </em>

<em>        MINIMUM=X</em>

<em>    }</em>

<em>}</em>

The answer to question B is X will not be replaced because X  replaced with MINIMUM only when if-part of this algorithm get executed. However, it is noted that X will not replace any value, if if-part will get executed, the Variable MINIMUM will get replaced with any value.

4 0
3 years ago
Which of the following is correct implementation code for the compareTo method in the ExpertPlayer class?
pochemuha

Complete Question:

The complete question is shown in uploaded image one and two.

Answer:

Answer is E

Explanation:

In order to gain understanding of this answer let look at  each code line by line

Considering Method one :

public int compareTo(Object obj)

{

This is the deceleration of the method.

ExpertPlayer rhs = (ExpertPlayer) obj;

On this line of code above an object (obj) that is passed into the method ( compareTo)is converted to type ExpertPlayer and is being assigned to a variable(rhs) of type ExpertPlayer

if(myRating ==  rhs.myRating) return 0;

else if(myRating < rhs.myRating) return 1;

else return 1;

}

This if conditional statement above will comparing the private variable myRating defined on ExpertPlayer with the private variable on the instance of the ExpertPlayer(i.e rhs.myRating)

some might ask why is compareTo method  accessing myRating which is private variable without getters or setters method. This is because the method (compareTo )and the variable(myRating) are defined in the  same class.

Looking at  this conditional statement we see that

if myRating == rhs.Rating it will return 0

if myRating < rhs.Rating it will return -1 a negative value

if myRating > rhs.Rating it will return 1 a positive value

Considering Method two

public int compareTo(Object obj)

{

As usual this code above is the deceleration of the method.

ExpertPLayer rhs = (ExpertPlayer) obj;

On this line of code above an object (obj) that is passed into the method ( compareTo)is converted to type ExpertPlayer and is being assigned to a variable(rhs) of type ExpertPlayer

return myRating – rhs.myRating;

}

On this line of code above a variable of an instance of ExpertPlayer class (i.e rhs.myRating) is subtracted from a private variable ( myrating) in ExpertPlayer class

Now looking at this code we see that if they are equal(i.e if myrating is equal to rhs.myRating) 0 will be returned

if myRating is less than rhs.myRating a negative value is returned

and if myRating is greater than rhs.myRating a positive value is return

comparing this with the first method we see that they are the same.

Considering Method Three

public int compareTo(Object obj)

{

As usual this code above is the deceleration of the method.

ExpertPLayer rhs = (ExpertPlayer) obj;

On this line of code above an object (obj) that is passed into the method ( compareTo)is converted to type ExpertPlayer and is being assigned to a variable(rhs) of type ExpertPlayer

if (getName().equals(rhs.getName()))

       return 0;

   else if (getName().compareTo(rhs.getName()) < 0)

       return -1;

   else

       return 1;

}

On the above snippet of code  myName a private variable gotten using getName() method from the HumanPlayer class which extended by ExpertPlayer class is compared with the myName variable of the instance of ExpertPlayer (i.e rhs) gotten using rhs.getName()

looking at this code above we see that it produces the same result as method one and two in that if the two compared items are the same it will return 0, if  getName() is less than rhs.getName() it will return -1 ,which is a negative value, and

if getName() is greater than rhs.getName() it will return 1 which is a positive value.

8 0
3 years ago
In most operating systems what is running application called?
Likurg_2 [28]

Answer:

I believe it is just a task. Since there exists(on windows) the Task Manager application, where you can stop any running <em>task, </em>I think that they are called tasks

Explanation:

5 0
3 years ago
What is the most important reason to create a backup of your files somewhere other than your computer
Marizza181 [45]
The most important reason we should make a backup of our files on a USB or other device is in case our computer suddenly dies. If something in it goes bad and it stops working, you will have then lost everything on your computer. But, if you make a save, you can buy another computer and upload everything onto the new one.
6 0
4 years ago
Five uses of the start button
Damm [24]

Starting something

Possibly turning it off

Making something work

Fixing the Start Button

Beginning something

5 0
3 years ago
Other questions:
  • Which are types of lines? Choose three answers.
    9·1 answer
  • A device that modulates digital data onto an analog signal and then demodulates the analog signal back to digital data is a ____
    8·1 answer
  • Cleaning the keyboard is the most important part of keeping your computer running at peak performance.
    5·2 answers
  • Word, by default, places a tab stop at every ____ mark on the ruler.
    6·1 answer
  • How to get the home button on your screen?
    13·1 answer
  • (1) Output a menu of automotive services and the corresponding cost of each service. (2 pts)Ex:Davy's auto shop servicesOil chan
    9·1 answer
  • How much memory will be occupied by black and white image​
    8·2 answers
  • Which devices are managed through device management? Device management is the process of managing----(blank)-----devices.
    15·1 answer
  • Need help with my cs110​
    11·1 answer
  • Which tags do you use to write the header and items of an ordered list on a web page?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!