SlideShare una empresa de Scribd logo
1 de 3
(TCO 2) Although the following code compiles and runs, the programmer broke some major
readability rules. Describe at least three changes that would make it easier for other programmers
to read and understand the code.
class Program
{
static void Main() //main
{
int a;
int Floater = 10; // ints
for(int i = 0;i < Floater;i++) /* loop */{
a=function(i);
Console.WriteLine(a);
}
Console.Read(); //read
}
public static int function(int a) /*function*/ {
return (int)(Math.Pow((double)a,2.0));
}
}
(Points : 20)
Solution
using System;
namespace Application
{
class Program
{
public static int function(int a) /*function*/ {
return (int)(Math.Pow((double)a,2.0));
}
static void Main() //main
{
int a;
int Floater = 10; // ints
for(int i = 0;i < Floater;i++) /* loop */{
a=function(i);
Console.WriteLine(a);
}
Console.Read(); //read
}
}
}
Output:

Más contenido relacionado

Similar a (TCO 2) Although the following code compiles and runs- the programmer.docx

C Programming ppt for beginners . Introduction
C Programming ppt for beginners . IntroductionC Programming ppt for beginners . Introduction
C Programming ppt for beginners . Introductionraghukatagall2
 
#OOP_D_ITS - 5th - C++ Oop Operator Overloading
#OOP_D_ITS - 5th - C++ Oop Operator Overloading#OOP_D_ITS - 5th - C++ Oop Operator Overloading
#OOP_D_ITS - 5th - C++ Oop Operator OverloadingHadziq Fabroyir
 
Principles of object oriented programing
Principles of object oriented programingPrinciples of object oriented programing
Principles of object oriented programingAhammed Alamin
 
chapter-8-function-overloading.pdf
chapter-8-function-overloading.pdfchapter-8-function-overloading.pdf
chapter-8-function-overloading.pdfstudy material
 
Object oriented programming system with C++
Object oriented programming system with C++Object oriented programming system with C++
Object oriented programming system with C++msharshitha03s
 
C# Variables and Operators
C# Variables and OperatorsC# Variables and Operators
C# Variables and OperatorsSunil OS
 
C Programming Language Step by Step Part 2
C Programming Language Step by Step Part 2C Programming Language Step by Step Part 2
C Programming Language Step by Step Part 2Rumman Ansari
 
(2) c sharp introduction_basics_part_i
(2) c sharp introduction_basics_part_i(2) c sharp introduction_basics_part_i
(2) c sharp introduction_basics_part_iNico Ludwig
 
embeddedc-lecture1-160404055102.pptx
embeddedc-lecture1-160404055102.pptxembeddedc-lecture1-160404055102.pptx
embeddedc-lecture1-160404055102.pptxsangeetaSS
 
Generalized Functors - Realizing Command Design Pattern in C++
Generalized Functors - Realizing Command Design Pattern in C++Generalized Functors - Realizing Command Design Pattern in C++
Generalized Functors - Realizing Command Design Pattern in C++ppd1961
 
Angular performance slides
Angular performance slidesAngular performance slides
Angular performance slidesDavid Barreto
 

Similar a (TCO 2) Although the following code compiles and runs- the programmer.docx (20)

C Programming ppt for beginners . Introduction
C Programming ppt for beginners . IntroductionC Programming ppt for beginners . Introduction
C Programming ppt for beginners . Introduction
 
C structure
C structureC structure
C structure
 
#OOP_D_ITS - 5th - C++ Oop Operator Overloading
#OOP_D_ITS - 5th - C++ Oop Operator Overloading#OOP_D_ITS - 5th - C++ Oop Operator Overloading
#OOP_D_ITS - 5th - C++ Oop Operator Overloading
 
Cpp
CppCpp
Cpp
 
Principles of object oriented programing
Principles of object oriented programingPrinciples of object oriented programing
Principles of object oriented programing
 
chapter-8-function-overloading.pdf
chapter-8-function-overloading.pdfchapter-8-function-overloading.pdf
chapter-8-function-overloading.pdf
 
Xiicsmonth
XiicsmonthXiicsmonth
Xiicsmonth
 
Activity 5
Activity 5Activity 5
Activity 5
 
Object oriented programming system with C++
Object oriented programming system with C++Object oriented programming system with C++
Object oriented programming system with C++
 
Embedded C - Lecture 1
Embedded C - Lecture 1Embedded C - Lecture 1
Embedded C - Lecture 1
 
C# Variables and Operators
C# Variables and OperatorsC# Variables and Operators
C# Variables and Operators
 
Srgoc dotnet
Srgoc dotnetSrgoc dotnet
Srgoc dotnet
 
C Programming Language Step by Step Part 2
C Programming Language Step by Step Part 2C Programming Language Step by Step Part 2
C Programming Language Step by Step Part 2
 
(2) c sharp introduction_basics_part_i
(2) c sharp introduction_basics_part_i(2) c sharp introduction_basics_part_i
(2) c sharp introduction_basics_part_i
 
embeddedc-lecture1-160404055102.pptx
embeddedc-lecture1-160404055102.pptxembeddedc-lecture1-160404055102.pptx
embeddedc-lecture1-160404055102.pptx
 
Fp201 unit2 1
Fp201 unit2 1Fp201 unit2 1
Fp201 unit2 1
 
Generalized Functors - Realizing Command Design Pattern in C++
Generalized Functors - Realizing Command Design Pattern in C++Generalized Functors - Realizing Command Design Pattern in C++
Generalized Functors - Realizing Command Design Pattern in C++
 
Angular performance slides
Angular performance slidesAngular performance slides
Angular performance slides
 
Python at Facebook
Python at FacebookPython at Facebook
Python at Facebook
 
Functions in C++
Functions in C++Functions in C++
Functions in C++
 

Más de pjoseph6

-- NaCIO- Bu4NHSO4 EtOAc (ethyl acetate) Benzophenone Benzhydrol Solut.docx
-- NaCIO- Bu4NHSO4 EtOAc (ethyl acetate) Benzophenone Benzhydrol Solut.docx-- NaCIO- Bu4NHSO4 EtOAc (ethyl acetate) Benzophenone Benzhydrol Solut.docx
-- NaCIO- Bu4NHSO4 EtOAc (ethyl acetate) Benzophenone Benzhydrol Solut.docxpjoseph6
 
(Multiple choice) Which one of the following statements is true- Expla.docx
(Multiple choice) Which one of the following statements is true- Expla.docx(Multiple choice) Which one of the following statements is true- Expla.docx
(Multiple choice) Which one of the following statements is true- Expla.docxpjoseph6
 
(Internal controls for plant assets) Harris- CPA- has accepted an enga.docx
(Internal controls for plant assets) Harris- CPA- has accepted an enga.docx(Internal controls for plant assets) Harris- CPA- has accepted an enga.docx
(Internal controls for plant assets) Harris- CPA- has accepted an enga.docxpjoseph6
 
- What is continuous linked settlement and how does it operate- - What.docx
- What is continuous linked settlement and how does it operate- - What.docx- What is continuous linked settlement and how does it operate- - What.docx
- What is continuous linked settlement and how does it operate- - What.docxpjoseph6
 
- What is a right-to-work state- What are the advantages or disadvanta.docx
- What is a right-to-work state- What are the advantages or disadvanta.docx- What is a right-to-work state- What are the advantages or disadvanta.docx
- What is a right-to-work state- What are the advantages or disadvanta.docxpjoseph6
 
(b) Ionization energy generally increases from left to right across th.docx
(b) Ionization energy generally increases from left to right across th.docx(b) Ionization energy generally increases from left to right across th.docx
(b) Ionization energy generally increases from left to right across th.docxpjoseph6
 
- How are corporate hierarchies related to the systems concept-Solutio.docx
- How are corporate hierarchies related to the systems concept-Solutio.docx- How are corporate hierarchies related to the systems concept-Solutio.docx
- How are corporate hierarchies related to the systems concept-Solutio.docxpjoseph6
 
- Describe in one or two paragraphs what is Web (8-10 lines) Your desc.docx
- Describe in one or two paragraphs what is Web (8-10 lines) Your desc.docx- Describe in one or two paragraphs what is Web (8-10 lines) Your desc.docx
- Describe in one or two paragraphs what is Web (8-10 lines) Your desc.docxpjoseph6
 
- Classify each of the following as a pure substance or a mixture- if.docx
- Classify each of the following as a pure substance or a mixture- if.docx- Classify each of the following as a pure substance or a mixture- if.docx
- Classify each of the following as a pure substance or a mixture- if.docxpjoseph6
 
- Below are nominal GDP and GDP deflators for four years- Calculate re.docx
- Below are nominal GDP and GDP deflators for four years- Calculate re.docx- Below are nominal GDP and GDP deflators for four years- Calculate re.docx
- Below are nominal GDP and GDP deflators for four years- Calculate re.docxpjoseph6
 

Más de pjoseph6 (10)

-- NaCIO- Bu4NHSO4 EtOAc (ethyl acetate) Benzophenone Benzhydrol Solut.docx
-- NaCIO- Bu4NHSO4 EtOAc (ethyl acetate) Benzophenone Benzhydrol Solut.docx-- NaCIO- Bu4NHSO4 EtOAc (ethyl acetate) Benzophenone Benzhydrol Solut.docx
-- NaCIO- Bu4NHSO4 EtOAc (ethyl acetate) Benzophenone Benzhydrol Solut.docx
 
(Multiple choice) Which one of the following statements is true- Expla.docx
(Multiple choice) Which one of the following statements is true- Expla.docx(Multiple choice) Which one of the following statements is true- Expla.docx
(Multiple choice) Which one of the following statements is true- Expla.docx
 
(Internal controls for plant assets) Harris- CPA- has accepted an enga.docx
(Internal controls for plant assets) Harris- CPA- has accepted an enga.docx(Internal controls for plant assets) Harris- CPA- has accepted an enga.docx
(Internal controls for plant assets) Harris- CPA- has accepted an enga.docx
 
- What is continuous linked settlement and how does it operate- - What.docx
- What is continuous linked settlement and how does it operate- - What.docx- What is continuous linked settlement and how does it operate- - What.docx
- What is continuous linked settlement and how does it operate- - What.docx
 
- What is a right-to-work state- What are the advantages or disadvanta.docx
- What is a right-to-work state- What are the advantages or disadvanta.docx- What is a right-to-work state- What are the advantages or disadvanta.docx
- What is a right-to-work state- What are the advantages or disadvanta.docx
 
(b) Ionization energy generally increases from left to right across th.docx
(b) Ionization energy generally increases from left to right across th.docx(b) Ionization energy generally increases from left to right across th.docx
(b) Ionization energy generally increases from left to right across th.docx
 
- How are corporate hierarchies related to the systems concept-Solutio.docx
- How are corporate hierarchies related to the systems concept-Solutio.docx- How are corporate hierarchies related to the systems concept-Solutio.docx
- How are corporate hierarchies related to the systems concept-Solutio.docx
 
- Describe in one or two paragraphs what is Web (8-10 lines) Your desc.docx
- Describe in one or two paragraphs what is Web (8-10 lines) Your desc.docx- Describe in one or two paragraphs what is Web (8-10 lines) Your desc.docx
- Describe in one or two paragraphs what is Web (8-10 lines) Your desc.docx
 
- Classify each of the following as a pure substance or a mixture- if.docx
- Classify each of the following as a pure substance or a mixture- if.docx- Classify each of the following as a pure substance or a mixture- if.docx
- Classify each of the following as a pure substance or a mixture- if.docx
 
- Below are nominal GDP and GDP deflators for four years- Calculate re.docx
- Below are nominal GDP and GDP deflators for four years- Calculate re.docx- Below are nominal GDP and GDP deflators for four years- Calculate re.docx
- Below are nominal GDP and GDP deflators for four years- Calculate re.docx
 

Último

How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management SystemChristalin Nelson
 
Integumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptIntegumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptshraddhaparab530
 
ROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxVanesaIglesias10
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
ICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfVanessa Camilleri
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4MiaBumagat1
 
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfErwinPantujan2
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptxmary850239
 
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxQ4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxlancelewisportillo
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptxiammrhaywood
 
Music 9 - 4th quarter - Vocal Music of the Romantic Period.pptx
Music 9 - 4th quarter - Vocal Music of the Romantic Period.pptxMusic 9 - 4th quarter - Vocal Music of the Romantic Period.pptx
Music 9 - 4th quarter - Vocal Music of the Romantic Period.pptxleah joy valeriano
 

Último (20)

How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management System
 
Integumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptIntegumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.ppt
 
ROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptx
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
ICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdf
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4
 
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptxYOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
 
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx
 
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxQ4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
 
Music 9 - 4th quarter - Vocal Music of the Romantic Period.pptx
Music 9 - 4th quarter - Vocal Music of the Romantic Period.pptxMusic 9 - 4th quarter - Vocal Music of the Romantic Period.pptx
Music 9 - 4th quarter - Vocal Music of the Romantic Period.pptx
 

(TCO 2) Although the following code compiles and runs- the programmer.docx

  • 1. (TCO 2) Although the following code compiles and runs, the programmer broke some major readability rules. Describe at least three changes that would make it easier for other programmers to read and understand the code. class Program { static void Main() //main { int a; int Floater = 10; // ints for(int i = 0;i < Floater;i++) /* loop */{ a=function(i); Console.WriteLine(a); } Console.Read(); //read } public static int function(int a) /*function*/ { return (int)(Math.Pow((double)a,2.0)); } } (Points : 20)
  • 2. Solution using System; namespace Application { class Program { public static int function(int a) /*function*/ { return (int)(Math.Pow((double)a,2.0)); } static void Main() //main { int a; int Floater = 10; // ints for(int i = 0;i < Floater;i++) /* loop */{ a=function(i); Console.WriteLine(a); } Console.Read(); //read