Quantcast

A community for students.

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

adunb8

  • 2 years ago

what is setw( ) and setprecision () and how do i use them?

  • This Question is Closed
  1. walters
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    setw() under iomanip use to make space by simply writing the value inside the parentheses setpreecision=it set a number of digits after a comma (it is also under iomanip)

  2. adunb8
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    here is my code : #include <iostream> #include <string> #include <iomanip> using namespace std; int main() { float a= 3.0, b= 5.0, c = 7.1, d=8.3, e=2.2, f=3.2 , g= 6.1, product ; int h=5 ; cout << " " << setprecision(2) << a << endl; cout << "*" << setprecision(2) << b << endl; cout << "----------" << endl; product = a*b ; cout << product << endl; system ("pause") ; }

  3. adunb8
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    however the setprecision is not working

  4. walters
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    #include <iostream> #include <string> #include<iomanip> using namespace std; int main() { float product ;//your type must b type float float a= 3.0, b= 5.0, c = 7.1, d=8.3, e=2.2, f=3.2 , g= 6.1; int h=5 ;//wat is the use of c,d,e,f,g,h cout << " " << a <<endl; cout<< "* "<<b<<endl; cout << "-------------" << endl; cout<<setprecision(2) <<fixed; product = 3.0*5.0 ; cout << product << endl; system ("pause") ; }

  5. walters
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    hey gotta sleep bye-bye

  6. nincompoop
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

    http://www.cplusplus.com/reference/iomanip/setprecision/

  7. adunb8
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    tnx!

  8. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Sign Up
Find more explanations on OpenStudy
Privacy Policy

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.