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
Nesterboy [21]
3 years ago
10

How do type declaration statements for simple variables affect the readability of a language, considering that some languages do

not require them?
Computers and Technology
1 answer:
pav-90 [236]3 years ago
4 0

Answer:

One key element in coding in any programming language is it's readability. Apart from adding comments to codes, another way to greatly enhance readability is by effective type declaration that are paramount in many programming languages such as Java, C, C++ and the likes. Type declaration allows for easy identification of data types and to differentiate between them. Not only does this enhance readability, it does also enhance optimal code-understandability.

Explanation:

You might be interested in
Write a program that reads raw data from a file that contains an inventory of items. The items should be sorted by name, and the
Anika [276]

Answer:

//C++ code

#include<iostream>

#include<fstream>

#include<iomanip>

using namespace std;

/*===============================================*/

// a structure called prod

struct prod

{

string name;// – a string, assumed to have no spaces

double price; // –adollaramount

int inStock; // – the number of items currently in stock.

};

//Fucntion Prototypes

void readInventory(prod products[], int& size);

/*===============================================*/

/*returns: a dollar amount, the total value of the inventory*/

double totalValue(prod products[], int size);

/*===============================================*/

// Sorts the given array by name

void sort(prod products[], int size);

/*===============================================*/

/*a report to a file called “report.txt”.

When the file fails to open, print

“Unable to open output file.” and end.*/

void writeReport(prod products[], int size);

/*===============================================*/

//Function definitions

/*===============================================*/

void writeReport(prod products[], int size)

{

ofstream outfile("report.txt");

outfile << fixed << setprecision(2);

if (!outfile)

{

cout << "Unable to open output file.\n";

return;

}

outfile << "+------------------------------+\n | Current Inventory |\n\

\n+------------------------------+\nNAME PRICE #\n\

\n-------------------- ------- ---\n";

for (int i = 0; i < size; i++)

{

outfile << products[i].name << " " << products[i].price << " " << products[i].inStock << endl;

}

outfile << "+------------------------------+\n";

outfile << "Number of products: " << size << endl;

outfile << "Inventory total value: " << totalValue(products, size) << endl;

cout << "Report written to file\n";

//close the output stream

outfile.close();

}

/*===============================================*/

void sort(prod products[], int size)

{

for (int i = 0; i < size; i++)

{

for (int j = i+1; j < size; j++)

{

if (products[i].name > products[j].name)

{

//swapping

prod temp = products[i];

products[i] = products[j];

products[j] = temp;

}

}

}

}

/*===============================================*/

double totalValue(prod products[], int size)

{

double total = 0;

for (int i = 0; i < size; i++)

{

total += products[i].inStock * products[i].price;

}

return total;

}

/*===============================================*/

void readInventory(prod products[], int& size)

{

// Open a file called “inventory.txt”

//and read the data from the file into the partial array

//.If the file fails to open,

//print “Unable to open input file”

//and set the number of products to 0.

size = 0;

ifstream inFile("inventory.txt");

if (!inFile)

{

cout << "Unable to open input file.\n";

return;

}

string name;

double price;

int qunatity;

while (inFile >> price >>qunatity >>name)

{

if (price != -1 && qunatity != -1 && name != "endofdata")

{

products[size].name = name;

products[size].inStock = qunatity;

products[size].price = price;

size++;

}

}

cout << "inventory read\n";

//close the stream

inFile.close();

}

/*===============================================*/

int main()

{

//declares a partial array of products

prod products[100];

int size;

// invokes readInventory()

readInventory(products, size);

// invokes sort()

sort(products, size);

// invokes writeReport()

writeReport(products, size);

// ends with the standard system pause.

system("pause");

return 0;

}

please see attachment for inventory text and output.

4 0
3 years ago
2. Kabel yang digunakan pada jangan wireline, sebagai
Mumz [18]
It’s b ........................................
7 0
3 years ago
The create_python_script function creates a new python script in the current working directory, adds the line of comments to it
Vika [28.1K]

Answer:

import os

def create_python_script(filename):

   comments = "# new python script file"

   with open(filename,"w+") as file:

       file.write(comments)

   filesize = os.path.getsize(filename)

   print(f"The size of the file is: {filesize}")

create_python_script("program.py")

Explanation:

The os module is a built-in python file that is used to interact with the operating system terminal. The with keyword is used to create and open a file with write privileges with no need to close the file.

The path.getsize() method is used to get the size of the newly created file which is printed in the console.

6 0
3 years ago
Describe how communication strengthens relationship at work and, as a result, increases your productivity
olganol [36]

Answer:

because it helps them understand their contributions and obligations towards the organisation.

Explanation:

In an organizational setup, the need for healthy and effective communication among employees and employers is a crucial element for the overall success of the organisation. Healthy and effective communication helps in the productivity of the employees because it helps them understand their contributions and obligations towards the organisation.

Good communication improves the employees' morality and sincerity as it helps them feel responsible and as an important member of the organisation. Hence, strengthening their relationships and, as a result, increasing their productivity and efficiency.

7 0
3 years ago
A ___________ is the smallest unit in a written language.
Delvig [45]
A. string? maybee its a string of units


8 0
3 years ago
Read 2 more answers
Other questions:
  • Changeover means that ____. (select all that apply)
    7·2 answers
  • What kind of voltage do solar cells generate? Solar cells produce ______ voltage which is not usable by most household appliance
    15·1 answer
  • When shooting in a windy outdoor environment a ___should be placed over the mic
    7·1 answer
  • Janelle is shopping for jeans from Express. She clicks on a style she likes. The site quickly presents her with a close-up view
    5·1 answer
  • Which statement is true about the elements of the interface of a presentation program? The status bar appears at the top of the
    14·2 answers
  • A(n ____ is a named group of formatting characteristics.
    7·1 answer
  • I was killed <br><br> යඞ <br><br> what do i do
    10·1 answer
  • Which are examples of basic text structures? Check all that apply.
    8·2 answers
  • Explain why computer professionals are engaged in technical services
    14·1 answer
  • Put simply, what tasks do algorithms help computers perform?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!