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
Debora [2.8K]
2 years ago
9

should variables that contain numbers always be declared as integer or floating-point data types? why or why not? name potential

examples.
Computers and Technology
1 answer:
Stells [14]2 years ago
6 0

No, it is not necessary that variables that contain numbers should always be declared as integer or floating-point data types.

It is not necessary that variables that contain numbers should be declared as integer and floating point data types. Because number can be declared with different data types.  As we know that data type is a vital aspect in programming. It describes the type of a value that is contained in a variable. It is the data type based on which memory is allocated to a number or any type of variables.

Numbers can be whole decimal/fractional, signed, unsigned, small, and long. Simply, they exist in a variety of values. According to their values range, the amount of memory is reserved.

Different programming languages offer different data types to store numbers, depending on their types and size. Let’s consider some examples of data types used in programming languages in order to declare variables holding numbers.

  • In Python int, float, and complex are the data types used to declare number type variables.
  • SQL uses INTEGER, SMALLINT , BIGINT , NUMERIC() , and DECIMAL() data types for numbers.
  • To deal with number type variables, Java has six predefined data types, such as int, long, short, byte, float, and double.
  • JavaScript uses a single data type called 'number' to declare numbers.
  • In C++, two fundamental data types, int and float, are used to represent numeric variables. But C++ is not only limited to these two data types. The data type char can also store numbers. Other data types for declaring numbers as variables are derived from int, float and char, such as short int, long int, signed int, unsigned int, double, long double, signed char, unsigned char etc. etc.

So in concluding remarks, declaring a number type variable is not only limited to using integers and floating-points data types. Rather it entirely depends on the respective programming language, and size and type of the number to be stored in the variable.

You can learn more about data types at

brainly.com/question/13438922

#SPJ4

You might be interested in
What did Muhammad do when he encountered opposition from Mecca’s city leaders? He brought more followers to Mecca. He relocated
Rudiy27

Answer:

He relocated from Mecca to the city of Medina.

Explanation:

5 0
3 years ago
Read 2 more answers
Why does the definition of fair use remain ambiguous?
bogdanovich [222]
Millions of dollars in legal fees have been spent attempting to define what qualifies as a fair use.

There are no hard-and-fast rules, only general guidelines and varied court decisions, because the judges and lawmakers who created the fair use exception did not want to limit its definition.

Like free speech, they wanted it to have an expansive meaning that could be open to interpretation.
8 0
3 years ago
There are a number of roles held by various users of online digital media, including contributors, conversationalists,
Maru [420]

Answer:

The mass media is a huge phenomenon. Through the various different platforms, print or broadcast, the media is able to reach millions of people like no other force. Without the media, powerful speeches by politicians would affect no one, local events would remain local, and performances by great actors would be seen only by the people in the immediate audience. The media overcomes distances, and builds a direct relationship with the audience. Many sociologist

4 0
3 years ago
Read 2 more answers
Write a subclass called SavingsAccount that extends Account and adds an interest rate variable. Write a constructor with 3 argum
AveGali [126]
Okayama sintered Nuni 19371
5 0
2 years ago
In this exercise, you will create a couple of helper methods for ArrayLists in a class called ArrayListMethods.
nata0808 [166]

Answer:

package lab1;

import java.util.ArrayList;

import java.util.Iterator;

public class ArrayListMethodsTester

{

public static void main(String[] args)

{

ArrayList<String> stringArray = new ArrayList<String>();

stringArray.add("This");

stringArray.add("is");

stringArray.add("an");

stringArray.add("ArrayList");

stringArray.add("of");

stringArray.add("Strings");

System.out.println("Printing the arraylist:");

ArrayListMethods.print(stringArray);

System.out.println("\nArrayList is condensing:");

ArrayListMethods.condense(stringArray);

ArrayListMethods.print(stringArray);

System.out.println("\nArrayList is duplicating:");

ArrayListMethods.duplicate(stringArray);

ArrayListMethods.print(stringArray);

}

}

class ArrayListMethods

{

static void print(ArrayList stringArray)

{

  Iterator it = stringArray.iterator();

  while (it.hasNext())

     System.out.println(it.next() + " ");

     

}

static void condense(ArrayList stringArray)

{

  int length=stringArray.size();

     

  ArrayList cloneArray=(ArrayList) stringArray.clone();

     

  stringArray.clear();

  StringBuilder sb=new StringBuilder("");

     

  for (int i = 0; i < (length/2); i++)

  {

      sb.append(cloneArray.get(i));

      sb.append(" ");    

  }

  stringArray.add(sb);

     

  StringBuilder sb1=new StringBuilder("");

  for (int i = (length/2); i < length; i++)

  {

      sb1.append(cloneArray.get(i));

      sb1.append(" ");    

  }

  stringArray.add(sb1);

  }

static void duplicate(ArrayList stringArray)

{

  for (int i = 0; i < stringArray.size(); i+=2)

  {

      stringArray.add(i+1,stringArray.get(i));

  }

}

}

Explanation:

  • Get the length of the arraylist  to copy the array into another arraylist .
  • Empty the array so that new content can be stored in it .
  • Use a loop to half of array_list.
  • Use a loop from half of array_list to the end of arraylist and  append all into a single string.
5 0
3 years ago
Other questions:
  • Which subexpression will be solved first in the given statement?
    8·1 answer
  • Categories of general purpose application software and examples each​
    13·1 answer
  • Which of the following words is an anatomy for cautious
    14·1 answer
  • In which type of land contract does the seller earn interest on the difference between what the seller owes on an existing loan
    14·1 answer
  • What is meant by algorithm?​
    12·1 answer
  • Henry must choose which type of smart speaker to use in his home. He asked you to help him decide which one will best suit his n
    11·1 answer
  • 1. Itemise the order in which BASIC executes arithmetic operation.
    13·1 answer
  • Instructions:Select the correct answer.
    8·2 answers
  • An interface is a class that contains only the method headings and each method heading is terminated with a semicolon. True Fals
    7·1 answer
  • Plsss help me plsssssss
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!