Click here to Skip to main content
15,992,698 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Write a program to input from the keyboard the “item_name,” which is a text string of length up to 40 characters, and the “item_price,” which is a float number. Print the contents of the variables in the proper format.

What I have tried:

I am still a beginner and have tried everything and still nothing.
Posted
Updated 24-Feb-22 12:50pm
Comments
Patrice T 24-Feb-22 19:35pm    
Show your work, or have a talk with your teacher.

We have no idea what you have tried so we cannot suggest ways to fix it. But you could spend some time learning the basic input output stream classes at Input/output library - cppreference.com[^].
 
Share this answer
 
You can read in a string of a known maximum length with getline:
C++
std::cin.getline(buffer, MAXCHR, '\n');

Reading in a float and printing everything out is so trivial that it appears in every cheap C++ tutorial.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900