#include <iostream>
uisng namespace std;
int main()
{
cout<<"Enter your three test scores and I will ";
<<" average them: ";
int score1, score2, score3,
cin>>score1>>score2>>score3;
double average;
average = (score1 + score2 + score3) / 3.0;
if (average = 100);
perfectScore = true; // set the flag variable
cout<<"Your average is "<<average
<<endl;
bool perfectScore;
if (perfectScore);
{
cout<<"Congratulations!\n";
cout<<"That's a perfect score.\n";
return 0;
}
ANSWER:-
// NOTE : I fixed all the error
#include <iostream>
using namespace std;
int main()
{
bool perfectScore=false;
cout<<"Enter your three test scores and I will average them:
";
int score1, score2, score3;
cin>>score1>>score2>>score3;
double average;
average = (score1 + score2 + score3) / 3.0;
if (average == 100)
perfectScore = true; // set the flag variable
cout<<"Your average is "<<average <<endl;
if (perfectScore)
{
cout<<"Congratulations!\n";
cout<<"That's a perfect score.\n";
return 0;
}
}
OUTPUT:-
// If any doubt please comment
#include <iostream> uisng namespace std; int main() { cout<<"Enter your three test scores and I...
1 // This program averages 3 test scores. 2 // It uses the variable perfectScore as a flag. 3 include <iostream> 4 using namespace std; 5 6 int main() 7 { 8 cout << "Enter your 3 test scores and I will "; 9 << "average them:"; 10 int score1, score2, score3, 11 cin >> score1 >> score2 >> score3; 12 double average; 13 average = (score1 + score2 + score3) / 3.0; 14 if (average = 100); 15 perfectScore...
Find errors in code and get 100% feedback!!
Foblem (30 Points) This program This programaverages > // It uses the ram has errors. Find the errors in the code: n averages 3 test scores. the variable perfect Score as a flag. Line # Line # include <iostream> using namespace std; int maino cout << "Enter your 3 test scores and I will ": <<"average them;": int score1, score2, score3, cin >> score1 >> score2 >> score3; double average; average (scorel...
#include<iostream> using namespace std; int main() { float num,avg,sum=0.0; int count=0; bool moreNumbers=true; cout<<"Enter grades:"<<endl; while(moreNumbers) { cin>>num; if(num < 0) { moreNumbers=false; } else { count = count+1; sum=sum+num; } } avg=sum/count; cout<<"Average grade:"<<avg<<endl; cout<<"How many grades were entered:"<<count<<endl; return 0; } Question: We need to add another loop to check input. Just like the input loop we already have, this one should use a boolean variable as a control. So, the logic could be something like this: Loop...
#include<iostream> #include<cstdlib> using namespace std; int main() { // create array of size 20 int arr[20]; int i; cout<<"scores : "; for( i = 0 ; i < 20 ; i++ ) { // generate a random number i range 70 - 100 an add it to arr arr[i] = rand() % 31 + 70; cout<<arr[i]<<" "; } // store the total score int total = 0;...
Write following program using Switch statement. #include <iostream> using namespace std; int main() int number; cout << "Enter an integer cin >> number; if (number > B) cout << You entered a positive integer: " << number << endl; else if (number (8) cout<<"You entered a negative integer: " << number << endl; cout << "You entered e." << endl; cout << "This line is always printed." return 0;
1 #include<iostream> 2 using namespace std; int main() int number; 7 cout < "Enter a number to p cin number; cout << "start:" rint the square numbers in reverse order from numb 10 ut << 1. N was: number return e; 12 13
#include <iostream> using namespace std; int main(void) { int SIZE; cout<<"Enter the size of the array"<<endl; cin>>SIZE; int *numlist = new int[SIZE]; // Read SIZE integers from the keyboard for (int i = 0; i<SIZE; i++ ) { cout << "Enter value #" << i+1 << ": "; cin >> numlist[i]; } // Display the numbers in a reverse order for (int i = SIZE; i > 0; i--...
#include <iostream> #include <chrono> using namespace std; double improvedPow(double x, int y) { // To be implemented by you } int main() { cout << "To calculate x^y ..." << endl; double x; int y; cout << "Please enter x: "; cin >> x; cout << "Please enter y: "; cin >> y; if(x == 0) { if (y > 0) cout << 0 << endl; else cout << "x^y is not defined" <<endl; } else { cout << improvedPow(x,y)...
#include <iostream> using namespace std; bool binarySearch(int arr[], int start, int end, int target){ //your code here } void fill(int arr[], int count){ for(int i = 0; i < count; i++){ cout << "Enter number: "; cin >> arr[i]; } } void display(int arr[], int count){ for(int i = 0; i < count; i++){ cout << arr[i] << endl; } } int main() { cout << "How many items: "; int count; cin >> count; int * arr = new...
include<iostream> #include<cstring> using namespace std; char reg[30]; int main() { //char reg[30]; char DNA[30]; int flag = 0; int n, ni, i, j, k; cout << "Enter a regular expression" << ; cin >> reg; cout << endl; n = reg.size(); for (int i = 0; i < n; i++) { strcpy(DNA, reg.substr(i, j)); ni = DNA.lenghth(); for (k = 0; k < ni;...