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
love history [14]
3 years ago
12

25 pts) Level 1 Programming Task Write the function getPop(char myCode[3]), which takes in a two-digit string representing the s

tate 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.
Computers and Technology
1 answer:
exis [7]3 years ago
5 0

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.    

You might be interested in
Help fast fast anyone
kkurt [141]

Answer:

True

Explanation:

:)

5 0
3 years ago
Alright, don't judge me, this is a question that involves my Childhood game PvZ GW 2. So I noticed mods and stuff that get uploa
Ann [662]

Answer:

honnnestlyyy, you might have to y0utub3 it

7 0
3 years ago
Read 2 more answers
Create 3–5 questions about your data that can be answered by sorting and filtering the database.
My name is Ann [436]

Answer:

With the help of sorting and filtering techniques we can get answers of may question.

Explanation

For example, there is a database of a book shop, we create few questions from that database, to get answer with the help of sorting and filtering techniques.

  1. Which one is the lowest selling book in the month?
  2. How many books available in the shop related to graphic designing?
  3. Which Book is the lowest Price Book in the category of Web Designing?
  4. Which Title Books are out of stock?
  5. Which Books are sale on Numbers and which on low arrange them in order?
7 0
4 years ago
Put these numbers in order from smallest to largest:<br> 1. 00101112<br> 2. 011110<br> 3. 011110112
Rina8888 [55]
The answer to this question is 3,2,1
8 0
3 years ago
Read 2 more answers
What is the size of the program counter for an avr that has a 1 kbyte rom capacity?
horsena [70]

Answer:

9 bits

Explanation:

 We all recognize 1 K bytes as =1024 bytes.  

And the storage medium used for program instructions are the non-volatile flash memories. The MCUs are always 8 bits, and a piece of the instructions revenues two or one 16-bit words. Besides we know program memory magnitude through the device name, and as an instance, the ATmega64x line emanates with 64KB of flash, and the ATmega32x line emanates with 32 KB. And there is nobody like off-chip program memory, and all of the codes that are being implemented by the AVR essentially be on the on-chip flash. However, this restraint is not ever applied to the AT94 FPSLIC AVR/FPGA chips. Also, you must know that AVR is a family of microcontrollers established by ATEL in 1996. It is a Harvard architecture type single-chip 8-bit RISC microcontroller. And it is supposed to be the first microcontroller which applied flash memory for storing the program They are heavily used in embedded systems.  

1k byte = 1024 bytes, However, if the program instruction takes 16 bits.  

And hence it only wishes 512.  

Here and now 512 = 10^9, and henceforth you necessitate 9 bits at minimum.  

excluding you can somehow paginate that (such as through one-bit pagination, you will be necessitating only 8 bits and so on.)  

Therefore the answer here = 9 bits.

5 0
4 years ago
Other questions:
  • The two types of one-time-password tokens are ______ and ______.
    10·2 answers
  • PLEASEEEEEEEEEEEEEEEEE HELPPPPPPPP
    15·1 answer
  • Write a function "cashier" that receives an int "c" for the number of items bought. The function will ask the price and task rat
    11·1 answer
  • Children's Web sites may combine educational and entertaining information and activities with interactive advertising and direct
    5·2 answers
  • What is the final value for X ?<br><br> x= 1<br><br> x=13<br><br> x= x+3<br><br> x=0
    9·1 answer
  • Which of the following was the primary purpose of muckraking, sensationalism, and yellow journalism in the early 1900s?
    11·1 answer
  • What is the depth of the following tree?
    10·1 answer
  • 5) The City Jail Technologies Department is constructing an application to allow users in the Crime Analysis Unit to query data
    11·1 answer
  • True or Fale A criminal defense attorney's main focus is to convict the accused of a crime, and a state prosecutor is to defend
    12·2 answers
  • 2.9.8 stop light codehs
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!