25 pts) Level 1 Programming Task Write the function getPop(char myCode[3]), which takes in a two-digit string representing the state or territory code and returns the associated state or territory population. The function should open and scan the file USpops.txt for the input two-digit code, myCode. If myCode is not found in the file, the function should return -1. Make sure to close the file once the file reading is complete.

Answers

Answer 1

Answer:

The method definition to this question can be defined as follows:

int getPop(char myCode[3])//defining a method getPop that takes char array in its parameter

{

FILE* f = NULL;//defining a pointer variable

int pop;//defining integer variable

char s_code[2];//defining char array state_code

char s_name[100];//defining char array stateName

f = fopen("state", "r");//using pointer variable that use fopen method for open file

if(f == NULL)//defining if block that check file is empty

{

return -1;//return value -1

}

while(!feof(f))//defining while loop for input value in file

{

fscanf(f, "%s %s %d",s_code, s_name, &pop);//input value

if(strncmp(myCode, s_code, 2) == 0)//use if block to compare string value

{

printf("Population for %s: %d", s_name, pop);//print value

return 0;//return 0

}

}

fclose(f);//close file

return 0;

}

Explanation:

In the above code, a method "getPop" is defined that accepts a character array "myCode" in its parameter, and inside the method, one pointer variable "f", one integer variable "pop", and two char array "s_code and s_name" is declared.

In the method firstly fopen method is used that holds a file and use if block to check it is not empty, if the condition is true it will give a value that is "-1".

In the next step, a while loop is declared, that input value and use if block to compare string value, and return 0, and at the last, it closed the file.    


Related Questions

how to create a structure using c# programming

Answers

Answer:

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

Explanation:

C# uses the struct keyword to declare structure.

The are used to store related data item.

For example the record of Student i-e his name, father name, address and class no can be declared using structure

using system

struct Student {

  public string name;

  public string father_name;

  public string address;

  public int class_no;

};

Answer for 3 and 4 please

Answers

Answer:

3. D: px

4. B: web page

Explanation:

All font sizes are measured in px unless specified otherwise (in em's for example).

The correct answer is a web page because itself is a unique file that displays multimedia components.

Answer:

Q3: Font size is measured in pt (point)  which can be converted into centimeter(cm)

Q4: The answer is webpage

Explanation:

Q3: Font size is measured in pt (point)  which can be converted into centimeter(cm)

Q4: A unique file with unique name and address is  a webpage.

because webserver and browser are software while website is collection of webpages.

having a bad day? enjoy this front view of phinias (can't spell his name)​

Answers

Answer:

ouch what happened to him

congrats you ruined my childhood

(thanks for the free points!!)

Research the significance of the UNIX core of macOS and write a few sentences describing your findings.

Answers

Answer:

The Unix core used in Apple's macOS is called Darwin which is similar to the BSD Unix operating system. The Darwin in macOS has evolved, providing a slick aqua-graphical user interface for users to interact with the application by clicking rather than writing Unix commands in terminals.

Explanation:

The macOS is the operating system used by Apple computer brands. The operating system is a subset of the Unix's BSD operating system. It still makes use of the traditional Unix terminal and scripts but with a few alterations.

The significance of the UNIX core of macOS can be briefly described as:

It makes use of an aqua-graphical user interface to easily communicate with the application for seamless use.

What is UNIX core?

This refers to the different kernel subsystems which are a part of the process management and memory allocation of a device.

Hence, the significance of the UNIX core of macOS has made it very easy for Apple users to communicate with their device in real time and also to power the phone.

Read more about UNIX here:

https://brainly.com/question/26338728

I really need help on this if you get it right I will say thank you my friend

Answers

I Think the answer is C

Answer:

A

Explanation:

A. Makes the the most sense

B. Not exactly

C. Doesn't make any sense

D. Complete Garbage

Write a program that asks the user for a word. Next, open up the movie reviews.txt file and examine every review one at a time. If a review contains the desired word you should make a note of the review score in an accumulator variable. Finally, produce some output that tells your user how that word was used across all reviews as well as the classification for this word (any score of 2.0 or higher can be considered

Answers

Answer:

import numpy as np

word = input("Enter a word: ")

acc = []

with open("Downloads/record-collection.txt", "r") as file:

   lines = file.readlines()

   for line in lines:

       if word in line:

           line = line.strip()

           acc.append(int(line[0]))

   if np.mean(acc) >= 2:

       print(f"The word {word} is a positive word")

       print(f"{word} appeared {len(acc)} times")

       print(f"the review of the word {word} is {round(np.mean(acc), 2)}")

   else:

       print(f"the word {word} is a negative word with review\

{round(np.mean(acc), 2)}")

Explanation:

The python program gets the text from the review file, using the user input word to get the definition of reviews based on the word, whether positive or negative.

The program uses the 'with' keyword to open the file and created the acc variable to hold the reviews gotten. The mean of the acc is calculated with the numpy mean method and if the mean is equal to or greater than 2 it is a positive word, else negative.

Write the code for the method getNewBox. The method getNewBox will return a GiftBox that has dimensions that are m times the dimensions of its GiftBox parameter, where m is a double parameter of the method.
For example, given the following code segment:
GiftBox gift = new Gift Box (3.0, 4.0, 5.0):
The call
getNewBox , 0, 5).
would return a GiftBox whose dimensions are: length = 1.5, width = 2.0, and height = 2.5 .

Answers

Answer:

public class GiftBox{

private int length;

private int width;

private int height;

 

public GiftBox(double length, double width, double height) {

this.length = length;

this.width = width;

this.height = height;

}

 

public static GiftBox getNewBox(GiftBox giftBox, double m) {

return new GiftBox(m * giftBox.length, m * giftBox.width, m * giftBox.height);

}

 

private boolean fitsInside(GiftBox giftBox) {

if(giftBox.length < this.length && giftBox.width <this.width

&& giftBox.height < this.height) {

return true;

}

return false;

}

 

public static void main(String []args){

GiftBox giftBox = new GiftBox(3.0 , 4.0, 5.0);

GiftBox newGiftBox = getNewBox(giftBox, 0.5);

System.out.println("New Box length: " + newGiftBox.length);

System.out.println("New Box width: " + newGiftBox.width);

System.out.println("New Box height: " + newGiftBox.height);

 

GiftBox gift = new GiftBox(3.0 , 4.0, 5.0);

GiftBox other = new GiftBox(2.1 , 3.2, 4.3);

GiftBox yetAnother = new GiftBox(2.0 , 5.0, 4.0);

 

System.out.println(gift.fitsInside(other));

System.out.println(gift.fitsInside(yetAnother));

}

}

Explanation:

The getNewBox is a public method in the GiftBox class in the Java source code above. It returns the GiftBox object instance increasing or multiplying the dimensions by the value of m of type double.

What dd command would you use to copy the contents of a partition named /dev/drive1 to another partition, called /dev/backup?

Answers

Answer:

dd if=/dev/drive1 of=/dev/backup

Explanation:

Linux operating system is an open-source computer application readily available to system operators. The terminal is a platform in the operating system used to write scripts like bash and directly communicate with the system kernel.

There are two commands used in bash to copy files, the "cp" and "dd". The dd is mostly used to copy files from one storage or partition to another. The syntax of dd is;

dd if= (source partition/directory) of= (target partition/directory)

What line of code makes the character pointer studentPointer point to the character variable userStudent?char userStudent = 'S';char* studentPointer;

Answers

Answer:

char* studentPointer = &userStudent;

Explanation:

Pointers in C are variables used to point to the location of another variable. To declare pointer, the data type must be specified (same as the variable it is pointing to), followed by an asterisk and then the name of the pointer. The reference of the target variable is also assigned to the pointer to allow direct changes from the pointer variable.

(10 points) Make a user interface to get 3 points from the user which will be placed on the coordinate plane. Then write a Python3 function to check whether the points entered forms a right triangle. And another Python3 function to check whether the points entered forms a equilateral triangle. Call your functions for three user-entered points on the coordinate plane.

Answers

Answer:

def cord_input():

Global coordinates

coordinates = {'x1': 0, 'y1': 0, 'x2':0, 'y2':0, 'x3':0, 'y3':0}

for key, i in enumerate(coordinates.keys()):

if i < 2:

index = 1

coordinates [key] = float(input(f"Enter {key} coordinate for point {index}: "))

elif i >= 2 and i < 4:

index = 2

coordinates [key] = float(input(f"Enter {key} coordinate for point {index}: "))

else:

index = 3

coordinates [key] = float(input(f"Enter {key} coordinate for point {index}: "))

def sides(p1, p2, p3):

nonlocal a, b, c

a = ((p2[0] - p1[0])**2) + ((p2[1] - p1[1])**2)

b = ((p3[0] - p2[0])**2) + ((p3[1] - p2[1])**2)

c = ((p3[0] -p1[0])**2) + ((p3[1] - p2[1])**2)

def is_right_triangle(p1, p2, p3):

sides(p1, p2, p3)

if a+b == c or b+c == a or a+c == b:

print(f"Sides {a}, {b} and {c}")

return True

else:

return False

def is_equilateral(p1, p2, p3):

sides(p1, p2, p3)

if a==b and b==c:

print(f"Sides {a}, {b} and {c}")

return True

else:

return False

cord_input()

Explanation:

The python code above defines four functions, cord_input (to input a global dictionary of coordinates), sides ( to calculate and assign the sides of the triangle), is_right_triangle ( to check if the coordinates are for a right-angle triangle), and is_equilateral for equilateral triangle check.

How does technology change thinking?

Answers

Answer:

Answer

Technology has altered human physiology. It makes us think differently, feel differently, even dream differently. It affects our memory, attention spans and sleep cycles. This is attributed to a scientific phenomenon known as neuroplasticity, or the brain's ability to alter its behavior based on new experiences.

have a nice day <3

if this helped, rate 5 stars

The question is in the photo

Answers

Answer:

a

the most suitable answer

Which Cisco IOS command will permit the engineer to modify the current configuration of the switch while it is powered on?

Answers

Configure terminal because Commands in this mode are written to the running configuration file as soon as you enter them (using the Enter key/Carriage Return). After you enter the configure terminal command, the system prompt changes from switch# to switch(config)#, indicating that the switch is in configuration mode.

Which of the following is a characteristic of vector graphics?

Answers

Answer:

A

Explanation:

Vector graphics consist of mathematical descriptions of shapes as a combination of these numerical vectors. Because the vector graphics define the path that the lines should take, rather than a set of points along the way, they can be used to calculate any number of points, and so can be used at any image resolution.

The characteristics of vector graphics are they are based on mathematical/geometric expression. The correct option is A.

What are vector graphics?

Vector graphics are mathematical descriptions of shapes created by combining these numerical vectors. Because vector graphics indicate the course that the lines should travel rather than a set of locations along the way, they may be used to calculate any number of points and thus work at any image resolution.

Raster images generate commonly used image files such as gif, jpeg, jpg, and so on. These can be made with picture editing software such as "Photoshop." Because these work on pixels, when we zoom the image, we can see tiny squares that are nothing more than pixels.

Therefore, the correct option is A, they are based on mathematical/geometric expression.

To learn more about vector graphics, refer to the link:

https://brainly.com/question/9759991

#SPJ2

A physical host machine has four quad-core CPUs, 16GB of RAM, 1TB of hard drive space, and two 1Gbps NICs. If we need to create four Windows 2008 servers, what will be the first bottleneck we should upgrade?a. CPUb. RAMc. Hard drived. NIC

Answers

Answer:

B. Ram

Explanation:

A random access memory (RAM) can be defined as the internal hardware memory which allows data to be read and written (changed) in a computer. Basically, a random access memory (RAM) is used for temporarily storing data such as software programs, operating system (OS), machine code and working data (data in current use) so that they are easily and rapidly accessible to the central processing unit (CPU).

Additionally, RAM is a volatile memory because any data stored in it would be lost or erased once the computer is turned off. Thus, it can only retain data while the computer is turned on and as such is considered to be a short-term memory.

There are two (2) main types of random access memory (RAM) and these are;

1. Static Random Access Memory (SRAM).

2. Dynamic Random Access Memory (DRAM).

Given a physical host machine that has four quad-core central processing units (CPUs), 16GB of random access memory (RAM), 1TB of hard drive space, and two 1Gbps network interface cards (NICs). Therefore, if we need to create four Windows 2008 servers, the first bottleneck we should upgrade is the random access memory (RAM) because it is typically the working memory that would be used by the server to store data, so they can be accessed easily and rapidly by the central processing unit (CPU).

Hence, the random access memory (RAM) may be increased from 16GB to 64GB or more depending on the client's requirements.

A method which applies to the class in which it is declared as a whole and not in response to method calls on a specific object is called a:_______

a. method call
b. an object method
c. private method
d. static method

Answers

Answer:

D) Static method

Explanation:

A static method is a method that is created only for the class and not it's instance variables or objects. Such methods can only be accessed by calling them through the class's name because they are not available to any class instance. A static method is created by prefixing the method's name with the keyword static.

A static method cannot be overridden or changed. You create a static method for a block of code that is not dependent on instance creation and that can easily be shared by all instances or objects.

Write a Python program to keep track of data for the following information in a medical clinic: doctors, patients, and patient_visits

Patients and Doctors have an ID, first name, and last name as common attributes. Doctors have these additional attributes: specialty (e.g. heart surgeon, ear-nose-throat specialist, or dermatologist), total hours worked, and hourly pay. Further, doctors keep track of the patient_visits. A patient_visit has the following attributes, number_of_visits to the clinic, the patient who is visiting, the doctor requested to be visited, and the number of hours needed for consultation. Based on the number of consultation hours, the doctor will get paid.


The following functions are required:

1. addVisit: this function adds a patient_visit to the doctor. A new visit will NOT be added if the doctor has already completed 40 hours or more of consultation. If this happens, an error is thrown mentioning that the doctor cannot have more visits this week.

2. calculatePay: this function calculates the payment for the doctor using the following logic: Each hour is worth AED 150 for the first two visits of the patient and all further visits are billed at AED 50.


3. calculateBill: this function calculates the bill for the patient, which displays the doctor's details, patient details, and payment details. An additional 5% of the total is added as VAT.


The student is required to identify classes, related attributes, and behaviors. Students are free to add as many attributes as required. The appropriate access modifiers (private, public, or protected) must be used while implementing class relationships. Proper documentation of code is mandatory. The student must also test the code, by creating at-least three objects. All classes must have a display function, and the program must have the functionality to print the current state of the objects.

Answers

This is too much to understand what you need the answer too. In my opinion I can’t answer this question

What is meant by the term visual communication?

Answers

Answer:

eye contact

Explanation:

The Bellman-Ford algorithm for the shortest path problem with negative edge weights will report that there exists a negative cycle if at least one edge can still be relaxed after performing nm times of relaxations. The algorithm, however, does not specify which cycle is a negative cycle. Design an algorithm to report one such cycle if it exists. You should make your algorithm runs as fast as possible.

Answers

Answer:

- Iterate over the Bellman-Ford algorithm n-1 time while tracking the parent vertex and store in an array.

- Do another iteration and if no relaxation of the edges occurs in the nth iteration then print of return "There are no negative cycle".

- Else, store the vertex of the relaxed edge at the nth iteration with a variable name.

- Then iterate over the vertexes starting from the store vertex until a cycle is found then print it out as the cycle of negative weight.

Explanation:

The Bellman-Ford algorithm can be used to detect a negative cycle in a graph. The program should iterate over the algorithm, in search of a relaxed edge. If any, the vertex of the specified edge is used as a starting point to get the target negative cycle.

Question #11
If A = 5 and B = 10, what is A* B equal to?
estion #2
estion # 3
restion #4
testion5
O 15
O Five
OTwo
O 50
Read Question

Answers

Answer:

Option 4: 50 is the correct answer.

Explanation:

Arithmetic operations can be performed using the programming languages. Some symbols used in programming languages are different from what we use in mathematics.

The symbol * is used to represent multiplication in programming languages.

Given

A = 5

B = 10

So, A*B will be equal to: 5*10 = 50

Hence,

Option 4: 50 is the correct answer.

Display ad traffic from mobile devices may appear to be unprofitable, but the ads might be profitable if

Answers

Answer:

They meet required amount of traffic or clicks.

Explanation:

AdSense is an advertisement platform for businesses. It advertises the registered business on various target client platform like mobile app and web app who allow these adverts for profit with a commission rate for a certain amount of traffic generated from the platform on the advertised business.

Which interpersonal skill is the most important for a telecom technician to develop?
teamwork
active listening
conflict resolution
social awareness

Answers

Answer: Interpersonal communication is the process of face-to-face exchange of thoughts, ideas, feelings and emotions between two or more people. This includes both verbal and nonverbal elements of personal interaction.

Explanation:

i think plz dont be mad

Chegg Suppose the heap is a full tree, size 2^n-1. what is the minimum number of steps to change a min heap to a max heap. Show your logic.

Answers

Answer:

Explanation:

We start from the bottom-most and rightmost internal node of min Heap and then heapify all internal modes in the bottom-up way to build the Max heap.

To build a heap, the following algorithm is implemented for any input array.

BUILD-HEAP(A)

   heapsize := size(A)

   for i := floor(heapsize/2) downto 1

       do HEAPIFY(A, i)

   end for

Convert the given array of elements into an almost complete binary tree.

Ensure that the tree is a max heap.

Check that every non-leaf node contains a greater or equal value element than its child nodes.

If there exists any node that does not satisfy the ordering property of max heap, swap the elements.

Start checking from a non-leaf node with the highest index (bottom to top and right to left).

What is the main reason for assigning roles to members of a group?

Answers

So that people with strengths in different areas can work on what they do best, plus it divides the workload.

The relational algebra expressions can be rearranged and achieve the same result but with a better processing time. A selection on an attribute can be moved from the outside of a query to a selection on just one of the relations being joined (if it isn't an attribute on both relations). Why would this be an improvement?
a. The selection on the joined results would cause a cartesian product operation
b. Moving the selection to the innermost relation keeps the depth of operations that have to be processed more shallow
c. This would reduce the number of tuples to involve in the join resulting in a more efficient query.
d. The outer selection would prevent the optimizer from picking the correct index

Answers

Answer:

c. This would reduce the number of tuples to involve in the join resulting in a more efficient query.

Explanation:

SQL or structured query language is a database querying language used to communicate or interact with databases. A database query could be as simple as returning all the columns from a database table to complex like joining several query results which in turn forms an algebra expression.

Every query statement or expression is executed with time, execution time needs to be minimized for efficiency, so, a well-arranged and reduced joining in the query improves the efficiency of the query.

Why is a bedroom considered a poor study environment?

Bedrooms are dimly lit.
Bedrooms are too small.
Bedrooms are too comfortable.
Bedrooms are messy and cluttered.

Answers

Bedrooms are too comfortable, I'm not sure if this is the answer

Answer:

It would basically be based on how you study and what your room is like. But my opinion would be

Bedrooms are Too Comfortable- which causes you to want to sleep or not due your work

Bedrooms are dimly lit- Which makes it hard for you to see your work and see anything

Bedrooms are too small- You will fell crushed and hard to focus (I would most likely choose this answer)

Bedrooms are messy and cluttered- You will not be able to concentrate and make it hard to study or do school work. ( I would choose this because I have experienced with this and I score higher in a cleaner environment and able to focus more)

Explanation: This would all depend on how you best work.

Hope this Helps!!

Which attitudes are most common among successful IT professionals?

Answers

openness to learning new things and interest in technology

emotional resilience and enjoyment of leadership positions

tough-mindedness and a focus on financial gain

empathetic and motivated by a concern for others


hopefully that helps!

The purpose of __________________ is to isolate the behavior of a given component of software. It is an excellent tool for software validation testing.a. white box testingb. special box testingc. class box testingd. black-box testing

Answers

Answer:

d.) black-box testing

Explanation:

Software testing can be regarded as procedures/process engage in the verification of a system, it helps in detection of failure in the software, then after knowing the defect , then it can be corrected. Black Box Testing can be regarded as a type of software testing method whereby internal structure as well as design of the item under test is not known by one testing it. In this testing internal structure of code/ program is unknown when testing the software, it is very useful in checking functionality of a particular application. Some of the black box testing techniques commonly used are; Equivalence Partitioning, Cause effect graphing as well as Boundary value analysis. It should be noted that the purpose of black-box testing is to isolate the behavior of a given component of software.

What is the best use of network in homes

Answers

Answer:

Spectrem

Explanation:

A hacker using information gathered from sniffing network traffic uses your banking credentials from a recent transaction to create nearly duplicate bank transfers but alters the target account to steal the funds. The attacker is reproducing traffic to re- create an event from previous transactions. This is an example of what type of attack?
A. Xmas attack
B. Smurf attack
C. DDoS attack
D. Replay attack

Answers

Answer: a replay attack, a replay attack is used so that the attacker can go sniff out the hash, and get whatever they are trying to get, then once it goes to the attacker it will go back to the original connection after replaying the hash

Hackers use packet sniffing attacks to intercept or steal potentially unprotected data from networks. A network-generated threat is a sniffing attack, also known as a packet sniffing assault. Thus, option D is correct.

What are the hacker using sniffing network?

Snooping gives ethical hackers a lot of information about how a network functions and how its users behave, which can be used to improve a company's cybersecurity.

Sniffing can, however, be utilized by unscrupulous hackers to conduct catastrophic attacks against gullible targets.

A network sniffer can detect someone using excessive bandwidth at a college or commercial organization and hunt them down.

Therefore, replay attacks are employed so that the attacker can find the hash and obtain the desired object. Once the attacker has received the object, the replay attack causes the object to return to the original connection.

Learn more about  sniffing network here:

https://brainly.com/question/10316246

#SPJ5

Other Questions
i need help this is due today at 4 What is the circumference of the circle below? In baseball/softball how many players play in the field at one time? Someone help me please 3.What is found around the roots of some plants that turns nitrogen from the form we cannot use to the form we can use? I will mark brainliest and give all points (100pts) Which is NOT a form of erosion? aRivers moving dirt bWater running downhill, carving out the land and pushing dirt to the side cWater evaporating and condensing dHeavy winds blowing soil to other locations HELP ASAP What is the Factor of :10x + 15 Solve the equation for all real solutions:16n^2-10n-5=6n Solve 6(3 + n) < 48.Show your work. Which of the following representations of ADAL would allow someone to construct a triangle NOT congruent to ADAL? WILL GIVE BRAINLIEST!! 20 PNTS!!Part A equation: 3r - 6Rewrite the equation from Part A by factoring the side that contains the variable r. On average, cody runs 4 miles in 38 minutes. How fast should he plan to run a 10-mile race if he maintains this place.A: 1 hour 3 minutesB: 1 hour 16 minutesC: 1 hour 35 minutesD: 2 hours 30 minutes can someone help me ! HELPPRead the excerpt from part 2 of "Flowers for Algernon."And I had been laughing at him too.Suddenly, I was furious at myself and all those who were smirking at him. I jumped up and shouted, "Shut up! Leave him alone! It's not his fault he can't understand! He can't help what he is! But for God's sake . . . he's still a human being!"How does Charlies realization about the dishwasher affect the plot?It causes him to defend the boy.It causes him to scold the boy.It causes him to help the boy clean.It causes him to mock the boy. HELPPPP PLEASEEE 100 POINTSdoes aerobic and anaerobic respiration have the same number of carbons, hydrogens and oxygens? Explain. 32% of =8 please. Thank you. Which will have a higher effective interest rate - a payday loan for $1500 thatis due in 12 days with a fee of $90, or a payday loan for $1500 that is due in10 days with a fee of $90?A. A payday loan for $1500 that is due in 12 days with a fee of $90,since it has the shorter periodB. A payday loan for $1500 that is due in 10 days with a fee of $90,since it has the shorter periodC. A payday loan for $1500 that is due in 10 days with a fee of $90.since it has the longer periodD. A payday loan for $1500 that is due in 12 days with a fee of $90,since it has the longer period 2. Water bottles are sold in cases of24. Select the expressions that canrepresent the total number of waterbottles in c cases.24 XC24 = 024 + c24 C24c difference between fluids and nonfluids