In this lab, you open a file and read input from that file in a prewritten C program. The program should read and print the names of flowers and whether they are grown in shade or sun. The data is stored in the input file named flowers.dat. Instructions Ensure the source code file named Flowers.cpp is open in the code editor. Declare the variables you will need. Write the C statements that will open the input file flowers.dat for reading. Write a while loop to read the input until EOF is reached. In the body of the loop, print the name of each flower and where it can be grown (sun or shade). Execute the program by clicking the Run button at the bottom of the screen.

Answers

Answer 1

Answer:

#include <stdio.h>

#include <string.h>

void main( )

{

array flowerProp[2];

FILE *fp; // file pointer

char flower[255]; // creating a char array to store data

fp = fopen("flowers.dat","r");

if (fp == NULL){

   printf("File flower.dat does not exist");

   return;

}

// assuming the growing condition is next line to the flower name.

while(fscanf(fp, "%s", flower)!=EOF){

   flowerProp.push(flower);

   if (flowerProp.length == 2){

       printf("%s: %s\n ", flowerProp[0], flowerProp[1]);

       memset(flowerProp, 0,0);

   }

}    

fclose (fp );

}

Explanation:

The algorithm creates a pointer to the memory location to the file starting position, the character size is used to get a string from the file line by line. Then it opens and checks if the file exists.

If the file exists, the while gets the name and growth condition of the flower, saves it to an array, prints the name and condition, and clears the array for the next flower type in the loop.


Related Questions

HELP ASAP WILL MARK BRAINLIEST

Answers

Answer:

C, C, D, B

Explanation:

What happens when in Word 2016 when the home ribbon tab is clicked on?

Answers

Answer: The home tab is opened up.

Explanation:

When using Word 2016 and the home ribbon tab is clicked on, the home tab is opened up. This tab houses the very basic functions of the word document, a lot of which have to be used if even a simple document needs to be typed.

This tab allows you to change the font as well as the font size and color. The page alignment is also set here as well as the text direction. Even headings can be customized here.

There are a lot more functions but the high level point is that the home tab is where the most basic of functions are, as shown in the attachment.

Given positive integer n, write a for loop that outputs the even numbers from n down to 0. If n is odd, start with the next lower even number.

Answers

Answer:

if(n % 2 == 0){

   for(int i = n; i >= 0; i-=2){

        System.out.println(i);

    }

}

else{

     for(int i = n - 1; i >= 0; i-=2){

        System.out.println(i);

     }

}

Sample output

Output when n = 12

12

10

8

6

4

2

0

Output when n = 21

20

18

16

14

12

10

8

6

4

2

0

Explanation:

The above code is written in Java.

The if block checks if n is even by finding the modulus/remainder of n with 2.  If the remainder is 0, then n is even. If n is even, then the for loop starts at i = n. At each cycle of the loop, the value of i is reduced by 2 and the value is outputted to the console.

If n is odd, then the else block is executed. In this case, the for loop starts at i = n - 1 which is the next lower even number. At each cycle of the loop, the value of i is reduced by 2 and the value is outputted to the console.

Sample outputs for given values of n have been provided above.

how do social media platform affect the social skills of your children ​

Answers

Answer:

Poor Impersonal Skills :(

Explanation:

Kids who spend their whole day on social media platforms may consider their virtual relation as a substitute for real ones. like cmon man

This may deteriorate the behavioral habits of kids Really dangerous

BUT Social media cqan also give kids more opportunities to communicate and practice social skills.  so ye

Write a recursive method named power that accepts two integers representing a base and an exponent and returns the base raised to that exponent. For example, the call of power(3, 4) should return 34 or 81 . If the exponent passed is negative, throw an IllegalArgumentException. Do not use loops or auxiliary data structures; solve the problem recursively. Also do not use the provided Java pow method in your solution.

Answers

Answer:

The method in java is as follows:

   public static int power(int num, int exp){

       if(exp == 0){            return 1;        }

       if(exp < 0){

           throw new IllegalArgumentException("Positive exponents only");        }

       else{            return (num*power(num, exp-1));        }

   }

Where

[tex]num\to[/tex] base

[tex]exp \to[/tex] exponent

Explanation:

This defines the method

   public static int power(int num, int exp){

This represents the base case, where the exponent is 0

       if(exp == 0){

If yes, the function returns 1

           return 1;        }

If exponent is negative, this throws illegal argument exception

       if(exp < 0){

           throw new IllegalArgumentException("Positive exponents only");        }

If exponents is positive, this calls the function recursively

       else{            return (num*power(num, exp-1));        }

   }

True or false? A process flow diagram is used to identify the steps an employee takes to complete a job

Answers

the answer is false because……….

What allows you to navigate up down left and right in a spreadsheet?

Answers

Answer:

scrollbar?

Explanation:

____________

Draw an ERD for the following problem with attributes, primary keys, cardinalities and participation constraints and specialization, if appropriate.
An information studies student wants to keep track of the following information. A publishers publishes two kinds of publications: books and journals. Any one publisher publishes at least one book and/or at least one journal. Each book can be written by one or more authors and one author can write one or more books. Each book and journal is characterized by one or more indexed keywords, which are represented by a keyword number and keyword. Not every keyword is used by the journals, however. Both books and journals have a unique number (such as ISBN# for a book and ISSN# for a journal), title and a publisher. For books, the student tracks the published year, all author information and their institutions. For journals, the student keeps the starting year first published, the number of issues to be published per year and the category of the journal (such as academic, newsletter, trade). Each publisher has name, address and phone.Each author has an ID number, name, address, phone, author's affiliated institution and the address of the institution. An author may be affiliated with more than one institution.The student would like to keep only authors who are participating in writing at least one book and institutions that have such authors.

Answers

Answer:

Following are the solution to the given question:

Explanation:

Ellipses are the attributes.Rectangle entities are shown.Rhombus is the relationship.The double rectangle is the weak entity.Is-A is a triangle relationship.

There has to be N: N between books and authors because one writer can write one or more books, and one or more writers can read each book.

The N: N eigenvalues also exist among authors or students as Authors who participate in the creation of one or more books and organizations with these writers will keep their tracking of them.

A sorted list of numbers contains 500 elements. Which of the following is closest to the maximum number of list elements that will be examined when performing a binary search for a value in the list?
A.) 10

B.) 50

C.) 250

D.) 500

Answers

The answer is B.

hope its correct

Following are the calculation to the maximum number of list elements:

The binary search algorithm starts in the center of the sorted list and continuously removes half of the elements until the target data is known or all of the items are removed. A list of 500 elements would be chopped in half up to 9 times (with a total of 10 elements examined).The particular prerequisites with 500 items and are decreased to 250 elements, then 125 aspects, then 62 elements, 31 aspects, 15 aspects, 7 aspects, 3 aspects, and ultimately 1 element.

Therefore, the final answer is "Option A"

Learn more about the binary search:

brainly.com/question/20712586

the laser printer operates on the same principle as a photocopier is it true or false.?​

Answers

true they both use laser technology

high quality permanent output can be produced using a​

Answers

Answer:

Using a printer of high efficiency cartilage.

state 4 basic operation performed by a computer​

Answers

Answer:

The processes are input, output, storing,processing, and controlling.

input, processing, output, and storage.

How do Computer Scientists use Binary Code?

Answers

Answer:

The digits 1 and 0 used in binary reflect the on and off states of a transistor. ... Each instruction is translated into machine code - simple binary codes that activate the CPU . Programmers write computer code and this is converted by a translator into binary instructions that the processor can execute .

The smalled valid zip code is 00501. The largest valid zip code is 89049. A program asks the user to enter a zip code and stores it in zip as an integer. So a zip code of 07307 would be stored as 7307. This means the smallest integer value allowed in zip is 501 and the largest integer value allowed in zip is 89049. Write a while loop that looks for BAD zip code values and asks the user for another zip code in that case. The loop will continue to execute as long as the user enters bad zip codes. Once they enter a good zip code the progam will display Thank you. The first line of code that asks for the zip code is below. You don't have to write this line, only the loop that comes after it.

Answers

Answer:

The program in Python is as follows:

zipp = int(input("Zip Code: "))

while (zipp > 89049 or zipp < 501):

   print("Bad zip code")

   zipp = int(input("Zip Code: "))

   

print("Thank you")

Explanation:

This gets input for the zip code [The given first line is missing from the question. So I had to put mine]

zipp = int(input("Zip Code: "))

This loop is repeated until the user enters a zip code between 501 and 89049 (inclusive)

while (zipp > 89049 or zipp < 501):

This prints bad zip code

   print("Bad zip code")

This gets input for another zip code

   zipp = int(input("Zip Code: "))

   

This prints thank you when the loop is exited (i.e. when a valid zip code is entered)

print("Thank you")

Develop a program working as a soda vending machine. The program should show the product menu with price and take user input for product number, quantity and pay amount. The output should show the total sale price including tax and the change. Organize the program with 4 functions and call them in main() based on the requirements.

Answers

Answer:

Explanation:

The following vending machine program is written in Python. It creates various functions to checkItems, check cash, check stock, calculate refund etc. It calls all the necessary functions inside the main() function. The output can be seen in the attached picture below.

class Item:

   def __init__(self, name, price, stock):

       self.name = name

       self.price = price

       self.stock = stock

   def updateStock(self, stock):

       self.stock = stock

   def buyFromStock(self):

       if self.stock == 0:

           # raise not item exception

           pass

       self.stock -= 1

class VendingMachine:

   def __init__(self):

       self.amount = 0

       self.items = []

   def addItem(self, item):

       self.items.append(item)

   def showItems(self):

       print('Items in Vending Machine \n----------------')

       for item in self.items:

           if item.stock == 0:

               self.items.remove(item)

       for item in self.items:

           print(item.name, item.price)

       print('----------------\n')

   def addCash(self, money):

       self.amount = self.amount + money

   def buyItem(self, item):

       if self.amount < item.price:

           print('You can\'t but this item. Insert more coins.')

       else:

           self.amount -= item.price

           item.buyFromStock()

           print('You chose ' +item.name)

           print('Cash remaining: ' + str(self.amount))

   def containsItem(self, wanted):

       ret = False

       for item in self.items:

           if item.name == wanted:

               ret = True

               break

       return ret

   def getItem(self, wanted):

       ret = None

       for item in self.items:

           if item.name == wanted:

               ret = item

               break

       return ret

   def insertAmountForItem(self, item):

       price = item.price

       while self.amount < price:

               self.amount = self.amount + float(input('insert ' + str(price - self.amount) + ': '))

   def calcRefund(self):

       if self.amount > 0:

           print(self.amount + " refunded.")

           self.amount = 0

       print('Thank you!\n')

def main():

   machine = VendingMachine()

   item1 = Item('Kit Kat',  1.5,  2)

   item2 = Item('Potato Chips', 1.75,  1)

   item3 = Item('Snickers',  2.0,  3)

   item4 = Item('Gum',  0.50, 1)

   item5 = Item('Doritos',0.75,  3)

   machine.addItem(item1)

   machine.addItem(item2)

   machine.addItem(item3)

   machine.addItem(item4)

   machine.addItem(item5)

   print('Welcome!\n----------------')

   continueBuying = True

   while continueBuying == True:

       machine.showItems()

       selected = input('select item: ')

       if machine.containsItem(selected):

           item = machine.getItem(selected)

           machine.insertAmountForItem(item)

           machine.buyItem(item)

           a = input('buy something else? (y/n): ')

           if a == 'n':

               continueBuying = False

               machine.calcRefund()

           else:

               continue

       else:

           print('Item not available. Select another item.')

           continue

if __name__ == "__main__":

   main()

Complete the sentences about interactive media.
With (cipher text, hypertext, teletext,) text is the main element of the content. (hypermedia, hypervideo, dynamic media) on the other hand, includes text as well as audio, video, and animation.

Answers

Answer:

teletext

dynamic media

Explanation:

Answer:

1, teletext
2, dynamic media

Explanation:

When you use the Query Editor to run a query that returns an xml type, theManagement Studio displays the XML data in blue with underlining to indicate that it is what?
a. link
b. misspelled
c. XML blue
d. XML Data
give brainliest to correct answer. no links and need asap please, thanks

Answers

Answer is c hope this helps

i need the solution to this task please anyone

Answers

Answer:

.

Explanation:

Write a function called PayLevel that returns a level given an Ssn as input. The level are: "Above Average" if the employee makes more than the average for their department "Average" if the employee makes the average for their department "Below Average" if the employee makes less than the average for their department

Answers

Answer:

Explanation:

Since no further information was provided I created the PayLevel function as requested. It takes the Ssn as input and checks it with a premade dictionary of Ssn numbers with their according salaries. Then it checks that salary against the average of all the salaries and prints out whether it is Above, Below, or Average. The output can be seen in the attached picture below.

employeeDict = {162564298: 40000, 131485785: 120000, 161524444: 65000, 333221845: 48000}

average = 68250

def PayLevel(Ssn):

   pay = employeeDict[Ssn]

   print("Employee " + str(Ssn) + " is:", end=" "),

   if pay > average:

       print("Above Average")

   elif pay < average:

       print("Below Average")

   else:

       print("Average")

PayLevel(161524444)

PayLevel(131485785)

When typing using the number row, your ___________________ is the proper finger to key the "6" key.

Answers

Answer:

your left pointer finger

Explanation:

Answer:

Your pointer finger, on ur left hand

Explanation:

Choose the item which best describes the free frame list. 1. a per process data structure of available physical memory 2. a global data structure of available logical memory 3. a global data structure of available physical memory 4. a global data structure of available secondary disk space

Answers

Answer:

A global data structure of available logical memory ( Option 2 )

Explanation:

A Free list is a data structure connecting unallotted regions in a memory together in a linked list (scheme for dynamic/logical memory allocation) , hence a free frame list is a global data structure of available Logical memory .

PLZ ANSWER WORTH 30 POINTS!!
If you want to alphabetize your rows, you should use the_______command.

A. Filter
B. View
C. Merge and Center
D. Sort

Answers

Answer:

D. Sort

Explanation:

The sort command will sort the rows into alphabetical order.

hiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii

Answers

Answer:

hhhhhhhhhhhhhhhhhiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii

Explanation:

Identify the correct syntax used to write to a text file. a. file = open('My_data.txt', 'w') file.write('This file contains data') b. file = open('My_data.txt', 'w') file.write(100) c. file = open('My_data.txt', 'w') file.write([100, 200, 300]) d. file = open('My_data.txt', 'a') file.write(['hello', 'hi', 'hey'])

Answers

Answer:

file = open('My_data.txt', 'w')

file.write('This file contains data')

Explanation:

Required

The correct syntax to write to file

From the question, we understand that we are to write to file and not append to the file.

This implies that the access mode will be w which stands for write

The first line of (a), (b) and (c) is correct.

(d) is incorrect

Solving further,

Only values of type string (i.e. str) can be written to file

With this, we can conclude that:

(a) is correct because 'This file contains data' is of type string

(b) and (c) are incorrect because, in (b), the value is of type integer and in (c), the type is list

Which is more important—book smarts or street smarts? Why? Which do you have more of?

Answers

Answer: book smart beacause book smart is intelligent and smart and learned the right thinks other than street smart people are unitelligent and incapable of achieving a higher education, but are more passionate and can usually find an answer to a problem through trial and error. We mostly have both cuz we learn in different ways

Explanation:

i hope this helps

brainliest??

Answer: book smart beacause book smart is intelligent and smart and learned the right thinks other than street smart people are unitelligent and incapable of achieving a higher education, but are more passionate and can usually find an answer to a problem through trial and error. We mostly have both cuz we learn in different ways

Conduct Internet research on CTSOs in your state or city. For your chosen career cluster, choose at least three organizations. Discuss each organization’s purpose and mission statement, as well as what type(s) of careers it helps prepare students for.

Answers

Answer:

CTSOs give CTE students additional opportunities outside of the classroom to grow and develop skills they will need within their chosen career paths. These opportunities range from after-school activities and programs to competitive events where students demonstrate their skills

hii

hope it helps have a niceee daaayyyyyy

Answer:

I want to pursue a career in banking. Jobs that require analytical and problem-solving skills fascinate me. After conducting online research, I found that banking falls in the career cluster of Finance.

I identified three CTSOs in my state that could help hone my skills in finance, bring out the leader in me, and make me a productive citizen. The three CTOs are:

Business Professionals of America

Distributive Education Clubs of America (DECA)

Future Business Leaders of America–Phi Beta Lambda (FBLA–PBL)

Business Professionals of America started in 1963. Its mission is to educate students to deal with situations in office settings. It doesn’t limit itself to office settings; rather, its scope is more dynamic because it prepares its members to deal with a variety of business situations.

FBLA-PBL is the largest and the oldest business student organization. Its mission is to bring business and education together in the same platform. Members can take part in various competitions at the local, state, and national level. The organization has partnerships with other organizations where members can apply the skills they learned in the classroom to real-life situations.

DECA is another organization that prepares its members for a dynamic career in finance, marketing, entrepreneurship, and hospitality. DECA seems to be the best fit for me for these reasons:

In addition to offering local, state, and national chapters, it also has an international chapter.

Membership is open throughout the year.

After I become a member of DECA, I’ll have access to all college and career preparation opportunities that DECA provides.

DECA gives scholarships worth $300,000 or more.

DECA organizes various conferences and competitive events where I can earn recognition if I perform well.

DECA’s membership dues are inexpensive, at $8 per person.

Explanation: SAMPLE ANSWER

How wireless communication might affect the development and implementations of internet of things?​

Answers

If people send a link don’t try them report them!

When parameters are passed between the calling code and the called function, formal and actual parameters are matched by: a.

Answers

Answer:

their relative positions in the parameter and argument lists.

Explanation:

In Computer programming, a variable can be defined as a placeholder or container for holding a piece of information that can be modified or edited.

Basically, variable stores information which is passed from the location of the method call directly to the method that is called by the program.

For example, they can serve as a model for a function; when used as an input, such as for passing a value to a function and when used as an output, such as for retrieving a value from the same function. Therefore, when you create variables in a function, you can can set the values for their parameters.

A parameter can be defined as a value that must be passed into a function, subroutine or procedure when it is called.

Generally, when parameters are passed between a calling code and the called function, formal and actual parameters are usually matched by their relative positions in the parameter and argument lists.

A formal parameter is simply an identifier declared in a method so as to represent the value that is being passed by a caller into the method.

An actual parameter refers to the actual value that is being passed by a caller into the method i.e the variables or values that are passed while a function is being called.

If you are writing an article on your favorite cuisine, which form of illustration would best fit the article?
Bill needs to make a presentation in which he has to represent data in the form of a pyramid. Which feature or menu option of a word processing program should Bill use?

Answers

Answer:

images

Explanation:

Adding images to the text gives it more life and makes the topic interesting

primary purpose of ms Excel​

Answers

MS Excel is a spreadsheet programme developed by Microsoft in 1985, with the sole purpose of helping businesses compile all their financial data, yearly credit, and yearly debit sheets. Fast forward to the future after 31 years, it is now the most commonly used program for creating graphs and pivot tables.
Other Questions
what is the sum of 2/11, 7/11, and 1/11 As part of an online cooking course, Dana needs to bake a simple cake. To get the recipe right, she prints out a set of graphical step-by-step instructions in a flow chart and places them next to her cooking station. Dana is MOST likely a(n) ______ learner.A. kinestheticB. visualC. auditoryD. linguistic Please help me due today !! Consider the purpose behind an extended warranty. For what types of products might it be worth purchasing an extended warranty? In what types of situations may an extended warranty not be worth the extra money? A Square has a perimeter of 80 ft. What is the area of the square. Bonus question for brainliest: What is the area of a circle that has a circumference of 80 ft? What angles can make a triangle, it has to do with acute, right, and obtuse angles. which two of these three make a triangle? 1. Who died first, Jesus or Julius Caesar? 2. Which Roman era lasted the longest: the Roman monarchy, the Roman republic, the Western Roman Empire or the Byzantine Empire?3. Did Jesus live during the Roman Republic or the Roman Empire?4. what led to the end of the Roman monarchy? 5. what led to the end of the Western Roman Empire? 6. how long did it take for Christianity to become an acceptable religion?7. Was Julius Caesar a Christian? How do you know? Ana does cannon balls into her pool. The pool has a radius of 14 feet. How much surface area does she have for her cannon balls? Show your calculations. a=1/2pa, solve for pNO LINKS PLEASEE!! IM BEGGING YOU NO LINKSS!!! Gina borrows from Regional Loan Company the funds to buy a car. The car secures the debt. Gina defaults on the loan. Regional takes possession of the car, planning to sell it to recover some of the unpaid debt. Before the creditor sells the car or enters into a contract for its sale, Gina can pay what she owes and take back the car. This is Suppose that the Department of Energy develops a new reversible engine that has a coefficient of performance (COP) of 4.0 when operated as a refrigerator and a COP of 5.0 when operated as a heat pump. What is its thermal efficiency when operated as a heat engine doing work PLSSS HELP PANICKINGThe sum of Alex and John's money is $48. Alex has $3 more than twice the amount John has. How much money do they each have? ASAP!! ILL GIVE BRAINLESTIn any given pair of similar three dimensional figures, if the ratio of the sides is a:b, then the ratio ofthe surface areas is...A:BA^3:B^A^-1:B^-1A^2:B^2 how is the modern day periodic table arranged group experiencing Oppression/loss of fredom? Donna is a computer repair person. She charges a flat fee of $20 for each computer plus an hourly charge of $9 per hour. Yesterday she worked on 6 computers and spent a total of 3 hours working. How much money did she make? Solve this riddle I come in lots of colors and I can swallow a 1000 sheep what am I? NEEED HELP 20 minutesGloria has two number cubes with faces numbered 1 through 6. She will roll each number cube once.Part A Make an organized list to show the sample space for rolling the two number cubes once.(You can make a list or a tree diagram to represent the sample space.)Part B How many possible outcomes are in the sample space for rolling the two number cubes once?Part C Gloria wants to roll the number cubes once and get a sum of 8 on the top faces.List the outcomes in the sample space that have a sum of 8.Part D What is the probability that Gloria will get a sum of 8 on the top faces when she rolls the two number cubes once? Can someone pls give me the answer to this? Your neighbor agreed to trudge through the snow to buy snow shovels for 10 families on your street! The store owner gave him a discount of $2 for each snow shovel, but it still cost your neighbor $85. Your family surprised two of your neighbors and paid for their shovels along with their own. How much does your family owe your neighbor for the three shovels? NEED HELP DUE TODAY!