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:26 | ISBN:9781285096261 | Edition: 4

Question

Identify the syntax error(s) (if any) in the following:
Line 1    using System
Line 2    namesspace ExerciseI
Line 3   {
Line 4         Problem2
Line 5         {
Line 6           static Main( )
Line 7           {
Line 8              console.write("ok")
Line 9           }
Line 10     }
Line 11 }

TextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbook

Answer

Line 1 has to be changed from  using System  to using System; (semicolon(;) is missing)

Line 2 has to be changed from  namesspace ExerciseI to namespace ExerciseI (spelling of namespace)

Line 4 has to be changed from Problem2 to class Problem2 (class is missing)

Line 6 has to be changed from static Main( ) to static void Main( ) (void is missing)

line 8 has to be changed from console.write("ok") to Console.Write("ok"); (Console is case sensitive and semicolon(;) is missing ) 

* The error(s) rectified program is

using System;
   namespace ExerciseI
   {
         class Problem2
         {
          static void Main( )
          {
              Console.Write("ok");
         }
    }
}

Output : ok

 

0 0

Discussions

Post the discussion to improve the above solution.