Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 12

FIND AND FIX

THE ERROR
EXAMPLE Error Correction
• using System; • System.out.print is a • using System;

• namespace syntax for output in • namespace


My_Problem{ java not in C#. My_Problem{

• class Program • class Program

• { • {

• static void Main(String[] • static void


args) Main(String[] args)
• {
• {
• Console.WriteLine(“He
• System.out.print(“Hello”)
llo”);
;
• }
• }
• }
• }
• }
Problem 1
using System;
namespace
namespace 1Add{
class Program
{
static void Main(String[] args)
{
Console.WriteLine(“ADD”);
Console.ReadKey();
}
}
}
Problem 2
using System;
namespace
namespace Convert{
class Program
{
static void Main(String[] args)
{
char text=‘a’;
sbyte conv= text;
Console.WriteLine(conv);

}
}
}
Problem 3
using System;
namespace
namespace Data_types{
class Program
{
static void Main(String[] args)
{
int abstract=1;
double return=2;

}
}
}
Problem 4
using System;
namespace
namespace Compare{
class Program
{
static void Main(Char[] args)
{
int x=5;
char comp=‘a’;
bool c= x>comp;
bool d= (bool)comp;
Console.WriteLine(c);
}
}
Problem 5
using System;
namespace
namespace sample{
class Program
{
static void Main(String[] args)
{
int num1=5;
Int num2= 10;
char letter=‘a’;
Int convert= (int) letter;
bool total=num1+num2;
Console.WriteLine(convert);
Console.WriteLine(total);
}
}
}
Answer 1
• ERROR • CORRECTION

using System;
namespace must not started to Add
numbers namespace
namespace 1Add{
class Program
{
static void Main(String[] args)
{
Console.WriteLine(“ADD”);
Console.ReadKey();
}
}
}
Answer 2
• CORRECTION
• ERROR
using System;
Char cannot be convert into sbyte namespace
namespace Convert{
class Program
{
static void Main(String[] args)
ushort, int, uint, long, ulong, float, or double
{
char text=‘a’;
sbyte conv= text;
Console.WriteLine(conv);

}
}
}
Answer 2
• CORRECTION
• ERROR using System;
Abstract and return is reserved namespace
words namespace Data_types{
class Program
{
Used proper identifiers static void Main(String[] args)
{
int abstract=1;
double return=2;

}
}
}
• CORRECTION

Answer 4 using System;


String [] args namespace
• ERROR
namespace Compare{
-main method declared is char class Program
instead of String
{
-char cannot be convert into static void Main(Char[] args)
boolean
{
Remove it
int x=5;
char comp=‘a’;
bool c= x>comp;
bool d= (bool)comp;
Console.WriteLine(c);
}
}
• CORRECTION

Answer 5 using System;


namespace
• ERROR namespace sample{
class Program
- Boolean cannot be have a
numerical return value {
static void Main(String[] args)
{
int num1=5;
int
Int num2= 10;
char letter=‘a’;
Int convert= (int) letter;
bool total=num1+num2;
Console.WriteLine(convert);
Console.WriteLine(total);
}
}

You might also like