Question

71.s0. segment Two (1e Errons // #includes and name space intentionally left out are not errors main(void) unsigned int j; short int month, days [18] 。 (31, 28, 31, 30, 31, 30, 31, 31, 1, 30, 31, 31,3, 穴〕 cout < ‘DAYS IN EACH MONTH, << endl; cout << MONTH DAYS << endl; for(j 0, j 12, j++); < cout <s left << setw(12) << j+1 < setw(3) <s month days< endl cout << endl < endl; system(pause); return e;

show all 10 mistakes

0 0
Add a comment Improve this question Transcribed image text
Answer #1

The 10 mistakes are given below:

main(void)

{

unsigned int j;

//the following line contains error 1: there are 12 elements so array size will be 12 not 10

//it will be month_days[12]

short int month_days[10]={31,28,31,30,31,30,31,31,30,31,30,31};

//the following line contains error 2: after cout there should be << operator instead <

//the following line also contains error 3: output string should be placed between " " instead of ' '

cout<'DAYS IN EACH MONTH'<<endl;

cout<<"MONTH DAYS"<<endl;

//the following line contains error 4: the syntax of for loop is incorrect ;

// it should be like for(j=0;j<12;j++) : semicolon ';' should be used inplace of comma ','

//the following line also contains error 5: after for loop statement ; should not be placed

//this should be like for(j=0;j<12;j++){...... }

for(j=0,j<12,j++);

{

//the following line contains error 6: array elements should be accessed with help of [] and index

//here only name of the array is given which is wrong ;it should be like month_days[j] instead of month_days

//the following line also contains error 7: this line statement semicolon should be placed

//here at end of line semicolon ';' is missing

cout<<left<<setw(12)<<j+1<<setw(3)<<month_days<<endl

cout<<endl<<endl;

//the following line contains error 8: this line statement should be placed outside of the for loop

//otherwise after every iteration enter should be pressed which is not usual it is kind of logical error

system("pause");

//the following line contains error 9: this line statement should be placed outside of the for loop

//otherwise the loop will end after first iteration only; this is also a logical error

return 0;

}

//Here in the last line there should be a closing '}' which will complete the syntax of main function

//So error 10 : missing of closing bracket '}' for main() function

/********************************************************/

The error free code is given below for understanding purpose:

main(void)

{

unsigned int j;

short int month_days[12]={31,28,31,30,31,30,31,31,30,31,30,31};

cout<<"DAYS IN EACH MONTH"<<endl;

cout<<"MONTH DAYS"<<endl;

for(j=0;j<12;j++)

{

cout<<left<<setw(12)<<j+1<<setw(3)<<month_days[j]<<endl;

cout<<endl<<endl;

}

system("pause");

return 0;

}

/*Hope this will help you. Thank you.*/

/*If this helps you, please let me know by giving a positive thumbs up. In case you have any queries, do let me know. I will revert back to you. Thank you!!*/

Add a comment
Know the answer?
Add Answer to:
show all 10 mistakes 71.s0. segment Two (1e Errons // #includes and name space intentionally left...
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
  • Expand the payroll program to combine two sorting techniques (Selection and Exchange sorts) for better efficiency...

    Expand the payroll program to combine two sorting techniques (Selection and Exchange sorts) for better efficiency in sorting the employee’s net pay. //I need to use an EXSEL sort in order to combine the selection and Exchange sorts for my program. I currently have a selection sort in there. Please help me with replacing this with the EXSEL sort. //My input files: //My current code with the sel sort. Please help me replace this with an EXSEL sort. #include <fstream>...

  • this is c code. please answer all questions on a piece of paper and show work....

    this is c code. please answer all questions on a piece of paper and show work. i need to prepare as i have a midterm i will have to be completing on paper 1) Bit Operators: This C program compiles and runs. What is its output? 1) #include <stdio.h> 2) void main (void) 3) unsigned char x =60; 4) 5) 6) 7) 8 ) 9) 10) 11) 12) 13) unsigned char a = x < 1; unsigned char b unsigned...

  • Assignment Predator / Prey Objectives Reading from and writing to text files Implementing mathematical formulas in...

    Assignment Predator / Prey Objectives Reading from and writing to text files Implementing mathematical formulas in C++ Implementing classes Using vectors Using command line arguments Modifying previously written code Tasks For this project, you will implement a simulation for predicting the future populations for a group of animals that we’ll call prey and their predators. Given the rate at which prey births exceed natural deaths, the rate of predation, the rate at which predator deaths exceeds births without a food...

  • C++ Programming Hi! Sorry for all the material attached. I simply need help in writing the...

    C++ Programming Hi! Sorry for all the material attached. I simply need help in writing the Facility.cpp file and the other files are included in case they're needed for understanding. I was able to complete the mayday.cpp file but am stuck on Facility. The following link contains a tar file with the files provided by the professor. Thank you so much in advanced! http://web.cs.ucdavis.edu/~fgygi/ecs40/homework/hw4/ Closer.h: #ifndef CLOSER_H #define CLOSER_H #include <string> #include "gcdistance.h" struct Closer { const double latitude, longitude;...

  • so i have my c++ code and ive been working on this for hours but i...

    so i have my c++ code and ive been working on this for hours but i cant get it to run im not allowed to use arrays. im not sure how to fix it thank you for the help our job is to write a menu driven program that can convert to display Morse Code ere is the menu the program should display Menu Alphabet Initials N-Numbers - Punctuations S = User Sentence Q- Quit Enter command the user chooses...

  • okay so here is my c++ code and the errors im really stuck on fixing what...

    okay so here is my c++ code and the errors im really stuck on fixing what i did wrong it seems to be the same repeated error our job is to write a menu driven program that can convert to display Morse Code ere is the menu the program should display Menu Alphabet Initials N-Numbers - Punctuations S = User Sentence Q- Quit Enter command the user chooses A your program should use a loop and your morse code printing...

  • Need help with C++ assignment Assignment 1 and .txt files are provided at the bottom. PART...

    Need help with C++ assignment Assignment 1 and .txt files are provided at the bottom. PART A PART B Assignment 1 #include <iostream> #include <string> #include <fstream> #include <iomanip> #include <stdio.h> #include <ctype.h> #include <string.h> #include <algorithm> using namespace std; /** This structure is to store the date and it has three integer fields **/ struct Date{    int day;    int month;    int year; }; /** This structure is to store the size of the box and it...

  • Assignment Overview In Part 1 of this assignment, you will write a main program and several...

    Assignment Overview In Part 1 of this assignment, you will write a main program and several classes to create and print a small database of baseball player data. The assignment has been split into two parts to encourage you to code your program in an incremental fashion, a technique that will be increasingly important as the semester goes on. Purpose This assignment reviews object-oriented programming concepts such as classes, methods, constructors, accessor methods, and access modifiers. It makes use of...

  • Question 1 An array is NOT: A - Made up of different data types. B - Subscripted by integers. C -...

    Question 1 An array is NOT: A - Made up of different data types. B - Subscripted by integers. C - A consecutive group of memory chunks. D - None of the choices. Question 2 How many times is the body of the loop executed? int i=1; while(true) { cout << i; if(++i==5) break; } A - Forever B - 4 C - 5 D - 6 E - 0 Question 3 What is wrong with the following piece of...

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