1. Write complete programs. These programs should be able to compile and run. No psuedocode is allowed. No comments are needed. These programs will be graded for syntax, semantics, and programming style.
Write a complete program to display the results for the area of a triangle. Formula (1/2) x base x height.
2.
Judge the correctness of the following identifiers. Write which are correct and not correct. Please note: that the ‘_’ is an underline character and not a space character. 2pts a piece
__intensify
sales per day
void5percent
4people
float_data
3.
Which semicolons are erroneous in the following program? Line numbers are included to help with your answer. Be specific in your description for where ; are not needed.
1: #include; <iostream>
2: using namespace std;
3: int; main();
4: {
5: char name;;
6: cout << "My name is; " << name << endl;
7: return 0;
8: };
Q1)
CODE:
#include <iostream>
using namespace std;
int main() {
float base,height;
cout<<"Enter the height of the triangle: "<<endl;
cin>>height;
cout<<"Enter the base of the triangle: "<<endl;
cin>>base;
cout<<"Area of triangle is: "<<(0.5*base*height)<<endl;
return 0;
}
OUTPUT:
Q2)
__intensify - correct
sales per day- Incorrect
void5percent- correct
4people- Incorrect
float_data- correct
Q3)
Question
1: #include; <iostream>
2: using namespace std;
3: int; main();
4: {
5: char name;;
6: cout << "My name is; " << name << endl;
7: return 0;
8: };
semi colon is required to terminate a statement. I have corrected the above code.
Solution
1: #include <iostream>
2: using namespace std;
3: int main()
4: {
5: char name;
6: cout << "My name is; " << name << endl;
7: return 0;
8: }
Please
upvote if you like my answer and comment below if you have
any queries or need any further explanation.
Get Answers For Free
Most questions answered within 1 hours.