SHARE
SPREAD
HELP

The Tradition of Sharing

Help your friends and juniors by posting answers to the questions that you know. Also post questions that are not available.


To start with, Sr2Jr’s first step is to reduce the expenses related to education. To achieve this goal Sr2Jr organized the textbook’s question and answers. Sr2Jr is community based and need your support to fill the question and answers. The question and answers posted will be available free of cost to all.

 

#
Authors:
Barbara Dolye
Chapter:
Introduction To Computing And Programming
Exercise:
Exercises
Question:23 | ISBN:9781285096261 | Edition: 4

Question

What must be changed in the segment of code in Exercise #22 to cause all of the
output to be displayed on one line?

TextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbook

Answer

The given Exercise #22 is

Line 1 // Example program – displaying output.
Line 2 using System;
Line 3 namespace ExerciseI
Line 4 {
Line 5 class Problem2
Line 6 {
Line 7 static void Main( )
Line 8 {
Line 9 Console.Write("Go ");
Line 10 Console.Write("Laugh ");
Line 11 Console.WriteLine("Out Loud");
Line 12 Console.Write("Think ");
Line 13 Console.Write("Happy");
Line 14 }
Line 15 }
Line 16 }

Change has to done  is

Line 11 has to canged from Console.WriteLine("Out Loud");  to Console.Write("Out Loud ");

*Changed program is

using System;
namespace ExerciseI
{
    class Problem2
    {
        static void Main()
        {
            Console.Write("Go ");
            Console.Write("Laugh ");
            Console.Write("Out Loud ");
            Console.Write("Think ");
            Console.Write("Happy");
        }
    }
}
 Output :

Go Laugh Out Loud Think HappyPress any key to continue . . .
 

 

0 0

Discussions

Post the discussion to improve the above solution.