Question

1. What is wrong with the following C++ program? #include <iostream> int main() { a = 4; b = 6; cout << a << + << b << =
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Here in first program, the datatype of a and b is not declared which would give an error.

I have tried running the code and here is the screen shot of error

/CCR/UserFiles/2.cpp:4:2: error: use of undeclared identifier a a=4; fatal error: too many errors emitted, stopping now [-f

In second program the value of pi is not defined which will give an error while running the program..

Here is the screen shot of the error..

~/CCR/UserFiles/2.cpp:5:18: error: use of undeclared identifier pi double ansl=exp(pi); 1 error generated. Run Again

The intended output is to compute e^π and π^e which can be done using the code given in screenshot

2.cpp 1 using namespace std; 2 #include <math.h> 3 int main() 4 1 double pi=3.1416; 6 double ansl=exp(pi); 7 cout<<epi :=<<

The output will be as follows:

epi :=23.1409 Value of e :=2.71828 pine :=22.4593 Run Again

Add a comment
Know the answer?
Add Answer to:
1. What is wrong with the following C++ program? #include <iostream> int main() { a =...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT