SlideShare ist ein Scribd-Unternehmen logo
1 von 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:

Weitere ähnliche Inhalte

Ähnlich wie (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
 

Ähnlich wie (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++
 

Mehr von 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
 

Mehr von 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
 

Kürzlich hochgeladen

Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin ClassesCeline George
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesEnergy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesShubhangi Sonawane
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
Role Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxRole Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxNikitaBankoti2
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxnegromaestrong
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 

Kürzlich hochgeladen (20)

Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesEnergy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Role Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxRole Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptx
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.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