What happens if you try to compile and run this program?

Last Updated on May 20, 2022 by Admin 2

What happens if you try to compile and run this program?

#include <iostream>
using namespace std;

int
main()
{
  double goodpi = 3.1415;
  double badpi = 3.2;
  cout << goodpi <<", ";
  cout << badpi <<", ";
  cout.setf(ios_base::showbase); //LINE O
  cout << goodpi <<", "; //LINE II
  cout << badpi <<", ";

  return 0;
}
  • the program outputs 3.1415, 3.2, 3.14150, 3.20000,
  • the program outputs 3.1415, 3.2, 3.14, 3.2,
  • compile error in LINE I
  • the program outputs 3, 3, 3.1415, 3.2
  • the program outputs 3, 3, 3.14, 3.20
  • runtime error at LINE II
  • compile error in LINE II
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments