SlideShare a Scribd company logo
1 of 6
Download to read offline
namespace Habib_OLA4
{
internal class Program
{
private int[] digits;
public BigNumber()
{
digits = new int[40];
}
public void Input(string input)
{
int startIndex = 0;
bool isNegative = false;
if (input[0] == '-')
{
isNegative = true;
startIndex = 1;
}
for (int i = 0; i < digits.Length; i++)
{
digits[i] = 0;
}
for (int i = startIndex; i < input.Length; i++)
{
digits[digits.Length - input.Length + i] = input[i] - '0';
}
if (isNegative)
{
Negate();
}
}
public override string ToString()
{
int startIndex = 0;
while (startIndex < digits.Length - 1 && digits[startIndex] == 0)
{
startIndex++;
}
if (digits[startIndex] < 0)
{
return "-" + new BigNumber(digits).ToString();
}
char[] chars = new char[digits.Length - startIndex];
for (int i = 0; i < chars.Length; i++)
{
chars[i] = (char)(digits[startIndex + i] + '0');
}
return new string(chars);
}
public BigNumber Add(BigNumber other)
{
BigNumber result = new BigNumber();
int carry = 0;
for (int i = digits.Length - 1; i >= 0; i--)
{
int sum = digits[i] + other.digits[i] + carry;
result.digits[i] = sum % 10;
carry = sum / 10;
}
return result;
}
public BigNumber Subtract(BigNumber other)
{
BigNumber result = new BigNumber();
int borrow = 0;
for (int i = digits.Length - 1; i >= 0; i--)
{
int difference = digits[i] - other.digits[i] - borrow;
if (difference < 0)
{
difference += 10;
borrow = 1;
}
else
{
borrow = 0;
}
result.digits[i] = difference;
}
return result;
}
public bool IsEqualTo(BigNumber other)
{
for (int i = 0; i < digits.Length; i++)
{
if (digits[i] != other.digits[i])
{
return false;
}
}
return true;
}
public bool IsNotEqualTo(BigNumber other)
{
return !IsEqualTo(other);
}
public bool IsGreaterThan(BigNumber other)
{
for (int i = 0; i < digits.Length; i++)
{
if (digits[i] > other.digits[i])
{
return true;
}
else if (digits[i] < other.digits[i])
{
return false;
}
}
return false;
}
public bool IsLessThan(BigNumber other)
{
for (int i = 0; i < digits.Length; i++)
{
if (digits[i] < other.digits[i])
{
return true;
}
else if (digits[i] > other.digits[i])
{
return false;
}
}
return false;
}
public bool IsGreaterThanOrEqualTo(BigNumber other)
{
for (int i = 0; i > digits.Length; i++)
{
if (digits[i] > other.digits[i])
{
return true;
}
else if (digits[i] < other.digits[i])
{
return false;
}
}
return false;
}
public static void Main(string[] args)
{
BigNumber integer1 = new BigNumber();
BigNumber integer2 = new BigNumber();
Console.Write("Enter first BigNumber: ");
integer1.Input(Console.ReadLine());
Console.Write("Enter second BigNumber: ");
integer2.Input(Console.ReadLine());
Console.WriteLine($"BigNumber 1: {integer1}");
Console.WriteLine($"BigNumber 2: {integer2}");
BigNumber result;
// add two BigNumbers
result = integer1.Add(integer2);
Console.WriteLine($"Add result: {result}");
// subtract two BigNumbers
result = integer1.Subtract(integer2);
Console.WriteLine($"Subtract result: {result}");
// compare two BigNumbers
Console.WriteLine($"BigNumber 1 is zero: {integer1.IsZero()}");
Console.WriteLine($"BigNumber 2 is zero: {integer2.IsZero()}");
Console.WriteLine($"BigNumber 1 is equal to BigNumber 2:
{integer1.IsEqualTo(integer2)}");
Console.WriteLine($"BigNumber 1 is not equal to BigNumber 2:
{integer1.IsNotEqualTo(integer2)}");
Console.WriteLine($"BigNumber 1 is greater than BigNumber 2:
{integer1.IsGreaterThan(integer2)}");
Console.WriteLine($"BigNumber 1 is less than BigNumber 2:
{integer1.IsLessThan(integer2)}");
Console.WriteLine($"BigNumber 1 is greater than or equal to BigNumber 2:
{integer1.IsGreaterThanOrEqualTo(integer2)}");
Console.WriteLine($"BigNumber 1 is less than or equal to BigNumber 2:
{integer1.IsLessThanOrEqualTo(integer2)}");
}
}
}
I have an error.
//This what the output support to look like
Sample Run 1:
Enter first BigNumber: 1234567890123456789012345678901234567890
Enter second BigNumber: 0987654321098765432109876543210987654321
BigNumber 1: 1234567890123456789012345678901234567890
BigNumber 2: 987654321098765432109876543210987654321
Add result: 2222222211222222221122222222112222222211
Subtract result: 246913569024691356902469135690246913569
BigNumber 1 is zero: False
BigNumber 2 is zero: False
BigNumber 1 is equal to BigNumber 2: False
BigNumber 1 is not equal to BigNumber 2: True
BigNumber 1 is greater than BigNumber 2: True
BigNumber 1 is less than BigNumber 2: False
BigNumber 1 is greater than or equal to BigNumber 2: True
BigNumber 1 is less than or equal to BigNumber 2: False
Press any key to continue . . .
Can you help me with the c# program?

More Related Content

Similar to namespace Habib_OLA4 { internal class Program { .pdf

Please help me make a UML for Java! Look at the code below and make a.docx
Please help me make a UML for Java! Look at the code below and make a.docxPlease help me make a UML for Java! Look at the code below and make a.docx
Please help me make a UML for Java! Look at the code below and make a.docxJakeT2gGrayp
 
From clever code to better code
From clever code to better codeFrom clever code to better code
From clever code to better codeDror Helper
 
Java AssignmentWrite a program using sortingsorting bubble,sele.pdf
Java AssignmentWrite a program using sortingsorting bubble,sele.pdfJava AssignmentWrite a program using sortingsorting bubble,sele.pdf
Java AssignmentWrite a program using sortingsorting bubble,sele.pdfeyewatchsystems
 
#include iostream #include string #include iomanip #incl.pdf
#include iostream #include string #include iomanip #incl.pdf#include iostream #include string #include iomanip #incl.pdf
#include iostream #include string #include iomanip #incl.pdfsudhinjv
 
include ltstdiohgtinclude ltstdlibhgtinclude l.pdf
include ltstdiohgtinclude ltstdlibhgtinclude l.pdfinclude ltstdiohgtinclude ltstdlibhgtinclude l.pdf
include ltstdiohgtinclude ltstdlibhgtinclude l.pdfadisainternational
 
2 BytesC++ course_2014_c4_ arrays
2 BytesC++ course_2014_c4_ arrays2 BytesC++ course_2014_c4_ arrays
2 BytesC++ course_2014_c4_ arrayskinan keshkeh
 
import java.util.; public class DecimalToBinary { public stat.pdf
import java.util.; public class DecimalToBinary { public stat.pdfimport java.util.; public class DecimalToBinary { public stat.pdf
import java.util.; public class DecimalToBinary { public stat.pdfanithareadymade
 
class Array { public static int getTotal(int[][]numbers ) { .pdf
class Array { public static int getTotal(int[][]numbers ) { .pdfclass Array { public static int getTotal(int[][]numbers ) { .pdf
class Array { public static int getTotal(int[][]numbers ) { .pdftrishacolsyn25353
 
public class Letter{private char letter;private int count;pu.pdf
public class Letter{private char letter;private int count;pu.pdfpublic class Letter{private char letter;private int count;pu.pdf
public class Letter{private char letter;private int count;pu.pdfanjanadistribution
 
CPP Language Basics - Reference
CPP Language Basics - ReferenceCPP Language Basics - Reference
CPP Language Basics - ReferenceMohammed Sikander
 
Accurate and Efficient Refactoring Detection in Commit History
Accurate and Efficient Refactoring Detection in Commit HistoryAccurate and Efficient Refactoring Detection in Commit History
Accurate and Efficient Refactoring Detection in Commit HistoryNikolaos Tsantalis
 
Connect() Mini 2016
Connect() Mini 2016Connect() Mini 2016
Connect() Mini 2016Jeff Chu
 

Similar to namespace Habib_OLA4 { internal class Program { .pdf (19)

Please help me make a UML for Java! Look at the code below and make a.docx
Please help me make a UML for Java! Look at the code below and make a.docxPlease help me make a UML for Java! Look at the code below and make a.docx
Please help me make a UML for Java! Look at the code below and make a.docx
 
types.pdf
types.pdftypes.pdf
types.pdf
 
From clever code to better code
From clever code to better codeFrom clever code to better code
From clever code to better code
 
Java AssignmentWrite a program using sortingsorting bubble,sele.pdf
Java AssignmentWrite a program using sortingsorting bubble,sele.pdfJava AssignmentWrite a program using sortingsorting bubble,sele.pdf
Java AssignmentWrite a program using sortingsorting bubble,sele.pdf
 
Cpp c++ 1
Cpp c++ 1Cpp c++ 1
Cpp c++ 1
 
#include iostream #include string #include iomanip #incl.pdf
#include iostream #include string #include iomanip #incl.pdf#include iostream #include string #include iomanip #incl.pdf
#include iostream #include string #include iomanip #incl.pdf
 
C programs
C programsC programs
C programs
 
include ltstdiohgtinclude ltstdlibhgtinclude l.pdf
include ltstdiohgtinclude ltstdlibhgtinclude l.pdfinclude ltstdiohgtinclude ltstdlibhgtinclude l.pdf
include ltstdiohgtinclude ltstdlibhgtinclude l.pdf
 
2 BytesC++ course_2014_c4_ arrays
2 BytesC++ course_2014_c4_ arrays2 BytesC++ course_2014_c4_ arrays
2 BytesC++ course_2014_c4_ arrays
 
cosc 281 hw2
cosc 281 hw2cosc 281 hw2
cosc 281 hw2
 
Codejunk Ignitesd
Codejunk IgnitesdCodejunk Ignitesd
Codejunk Ignitesd
 
Lab Question
Lab QuestionLab Question
Lab Question
 
import java.util.; public class DecimalToBinary { public stat.pdf
import java.util.; public class DecimalToBinary { public stat.pdfimport java.util.; public class DecimalToBinary { public stat.pdf
import java.util.; public class DecimalToBinary { public stat.pdf
 
Code
CodeCode
Code
 
class Array { public static int getTotal(int[][]numbers ) { .pdf
class Array { public static int getTotal(int[][]numbers ) { .pdfclass Array { public static int getTotal(int[][]numbers ) { .pdf
class Array { public static int getTotal(int[][]numbers ) { .pdf
 
public class Letter{private char letter;private int count;pu.pdf
public class Letter{private char letter;private int count;pu.pdfpublic class Letter{private char letter;private int count;pu.pdf
public class Letter{private char letter;private int count;pu.pdf
 
CPP Language Basics - Reference
CPP Language Basics - ReferenceCPP Language Basics - Reference
CPP Language Basics - Reference
 
Accurate and Efficient Refactoring Detection in Commit History
Accurate and Efficient Refactoring Detection in Commit HistoryAccurate and Efficient Refactoring Detection in Commit History
Accurate and Efficient Refactoring Detection in Commit History
 
Connect() Mini 2016
Connect() Mini 2016Connect() Mini 2016
Connect() Mini 2016
 

More from amazonedistributors

Need help answering 1(a-d). Service DepartmentsProduction Department.pdf
Need help answering 1(a-d). Service DepartmentsProduction Department.pdfNeed help answering 1(a-d). Service DepartmentsProduction Department.pdf
Need help answering 1(a-d). Service DepartmentsProduction Department.pdfamazonedistributors
 
Need correct answer please using Laplace Smoothing Method Please ..pdf
Need correct answer please using Laplace Smoothing Method Please ..pdfNeed correct answer please using Laplace Smoothing Method Please ..pdf
Need correct answer please using Laplace Smoothing Method Please ..pdfamazonedistributors
 
Necesito ayuda para responder la respuesta del art�culo. Los abuel.pdf
Necesito ayuda para responder la respuesta del art�culo. Los abuel.pdfNecesito ayuda para responder la respuesta del art�culo. Los abuel.pdf
Necesito ayuda para responder la respuesta del art�culo. Los abuel.pdfamazonedistributors
 
Necesita ayuda para responder las siguientes preguntasstarbucks.pdf
Necesita ayuda para responder las siguientes preguntasstarbucks.pdfNecesita ayuda para responder las siguientes preguntasstarbucks.pdf
Necesita ayuda para responder las siguientes preguntasstarbucks.pdfamazonedistributors
 
Nash Incs EPS is $6.72 and its dividend payout ratio is 0.7. the co.pdf
Nash Incs EPS is $6.72 and its dividend payout ratio is 0.7. the co.pdfNash Incs EPS is $6.72 and its dividend payout ratio is 0.7. the co.pdf
Nash Incs EPS is $6.72 and its dividend payout ratio is 0.7. the co.pdfamazonedistributors
 
NASA must determine how many of three types of objects to bring on b.pdf
NASA must determine how many of three types of objects to bring on b.pdfNASA must determine how many of three types of objects to bring on b.pdf
NASA must determine how many of three types of objects to bring on b.pdfamazonedistributors
 
Name these structures A. Identify this region B. Identify these fold.pdf
Name these structures A. Identify this region B. Identify these fold.pdfName these structures A. Identify this region B. Identify these fold.pdf
Name these structures A. Identify this region B. Identify these fold.pdfamazonedistributors
 
n2=25n1=12x=115y=107ay=20oy=11 The confdence mbervai is (Fiound to two.pdf
n2=25n1=12x=115y=107ay=20oy=11 The confdence mbervai is (Fiound to two.pdfn2=25n1=12x=115y=107ay=20oy=11 The confdence mbervai is (Fiound to two.pdf
n2=25n1=12x=115y=107ay=20oy=11 The confdence mbervai is (Fiound to two.pdfamazonedistributors
 
No plagiarism and at least 250 wordsBriefly describe the dif.pdf
No plagiarism and at least 250 wordsBriefly describe the dif.pdfNo plagiarism and at least 250 wordsBriefly describe the dif.pdf
No plagiarism and at least 250 wordsBriefly describe the dif.pdfamazonedistributors
 
no need to invlude comments in the code. 1. Follow the FDR to im.pdf
no need to invlude comments in the code. 1. Follow the FDR to im.pdfno need to invlude comments in the code. 1. Follow the FDR to im.pdf
no need to invlude comments in the code. 1. Follow the FDR to im.pdfamazonedistributors
 
Nonylphenol (NP) is commonly found in municipal wastewater and solid.pdf
Nonylphenol (NP) is commonly found in municipal wastewater and solid.pdfNonylphenol (NP) is commonly found in municipal wastewater and solid.pdf
Nonylphenol (NP) is commonly found in municipal wastewater and solid.pdfamazonedistributors
 
North Korea Is a socialist state. The system is a single-party regim.pdf
North Korea Is a socialist state. The system is a single-party regim.pdfNorth Korea Is a socialist state. The system is a single-party regim.pdf
North Korea Is a socialist state. The system is a single-party regim.pdfamazonedistributors
 
Noel Arrold podr�a haber terminado en trigo. O en el sal�n de clases.pdf
Noel Arrold podr�a haber terminado en trigo. O en el sal�n de clases.pdfNoel Arrold podr�a haber terminado en trigo. O en el sal�n de clases.pdf
Noel Arrold podr�a haber terminado en trigo. O en el sal�n de clases.pdfamazonedistributors
 
Nike vendiendo una l�nea de ropa para acompa�ar su producto principa.pdf
Nike vendiendo una l�nea de ropa para acompa�ar su producto principa.pdfNike vendiendo una l�nea de ropa para acompa�ar su producto principa.pdf
Nike vendiendo una l�nea de ropa para acompa�ar su producto principa.pdfamazonedistributors
 
Ninna Banks is responsible for recording cash disbursements, prepari.pdf
Ninna Banks is responsible for recording cash disbursements, prepari.pdfNinna Banks is responsible for recording cash disbursements, prepari.pdf
Ninna Banks is responsible for recording cash disbursements, prepari.pdfamazonedistributors
 
Nike Case StudyDoes Jeff Ballinger have a convincing argument abo.pdf
Nike Case StudyDoes Jeff Ballinger have a convincing argument abo.pdfNike Case StudyDoes Jeff Ballinger have a convincing argument abo.pdf
Nike Case StudyDoes Jeff Ballinger have a convincing argument abo.pdfamazonedistributors
 
NIIF 9 instrumento financiero permite el uso de contabilidad de cobe.pdf
NIIF 9 instrumento financiero permite el uso de contabilidad de cobe.pdfNIIF 9 instrumento financiero permite el uso de contabilidad de cobe.pdf
NIIF 9 instrumento financiero permite el uso de contabilidad de cobe.pdfamazonedistributors
 
Nicholas is currently in eighth grade and intends to attend a state .pdf
Nicholas is currently in eighth grade and intends to attend a state .pdfNicholas is currently in eighth grade and intends to attend a state .pdf
Nicholas is currently in eighth grade and intends to attend a state .pdfamazonedistributors
 
NetworkingShow the commandsUsing nmcli , create a new network .pdf
NetworkingShow the commandsUsing nmcli , create a new network .pdfNetworkingShow the commandsUsing nmcli , create a new network .pdf
NetworkingShow the commandsUsing nmcli , create a new network .pdfamazonedistributors
 
Network Environment & Configuration Requirements You are a support t.pdf
Network Environment & Configuration Requirements You are a support t.pdfNetwork Environment & Configuration Requirements You are a support t.pdf
Network Environment & Configuration Requirements You are a support t.pdfamazonedistributors
 

More from amazonedistributors (20)

Need help answering 1(a-d). Service DepartmentsProduction Department.pdf
Need help answering 1(a-d). Service DepartmentsProduction Department.pdfNeed help answering 1(a-d). Service DepartmentsProduction Department.pdf
Need help answering 1(a-d). Service DepartmentsProduction Department.pdf
 
Need correct answer please using Laplace Smoothing Method Please ..pdf
Need correct answer please using Laplace Smoothing Method Please ..pdfNeed correct answer please using Laplace Smoothing Method Please ..pdf
Need correct answer please using Laplace Smoothing Method Please ..pdf
 
Necesito ayuda para responder la respuesta del art�culo. Los abuel.pdf
Necesito ayuda para responder la respuesta del art�culo. Los abuel.pdfNecesito ayuda para responder la respuesta del art�culo. Los abuel.pdf
Necesito ayuda para responder la respuesta del art�culo. Los abuel.pdf
 
Necesita ayuda para responder las siguientes preguntasstarbucks.pdf
Necesita ayuda para responder las siguientes preguntasstarbucks.pdfNecesita ayuda para responder las siguientes preguntasstarbucks.pdf
Necesita ayuda para responder las siguientes preguntasstarbucks.pdf
 
Nash Incs EPS is $6.72 and its dividend payout ratio is 0.7. the co.pdf
Nash Incs EPS is $6.72 and its dividend payout ratio is 0.7. the co.pdfNash Incs EPS is $6.72 and its dividend payout ratio is 0.7. the co.pdf
Nash Incs EPS is $6.72 and its dividend payout ratio is 0.7. the co.pdf
 
NASA must determine how many of three types of objects to bring on b.pdf
NASA must determine how many of three types of objects to bring on b.pdfNASA must determine how many of three types of objects to bring on b.pdf
NASA must determine how many of three types of objects to bring on b.pdf
 
Name these structures A. Identify this region B. Identify these fold.pdf
Name these structures A. Identify this region B. Identify these fold.pdfName these structures A. Identify this region B. Identify these fold.pdf
Name these structures A. Identify this region B. Identify these fold.pdf
 
n2=25n1=12x=115y=107ay=20oy=11 The confdence mbervai is (Fiound to two.pdf
n2=25n1=12x=115y=107ay=20oy=11 The confdence mbervai is (Fiound to two.pdfn2=25n1=12x=115y=107ay=20oy=11 The confdence mbervai is (Fiound to two.pdf
n2=25n1=12x=115y=107ay=20oy=11 The confdence mbervai is (Fiound to two.pdf
 
No plagiarism and at least 250 wordsBriefly describe the dif.pdf
No plagiarism and at least 250 wordsBriefly describe the dif.pdfNo plagiarism and at least 250 wordsBriefly describe the dif.pdf
No plagiarism and at least 250 wordsBriefly describe the dif.pdf
 
no need to invlude comments in the code. 1. Follow the FDR to im.pdf
no need to invlude comments in the code. 1. Follow the FDR to im.pdfno need to invlude comments in the code. 1. Follow the FDR to im.pdf
no need to invlude comments in the code. 1. Follow the FDR to im.pdf
 
Nonylphenol (NP) is commonly found in municipal wastewater and solid.pdf
Nonylphenol (NP) is commonly found in municipal wastewater and solid.pdfNonylphenol (NP) is commonly found in municipal wastewater and solid.pdf
Nonylphenol (NP) is commonly found in municipal wastewater and solid.pdf
 
North Korea Is a socialist state. The system is a single-party regim.pdf
North Korea Is a socialist state. The system is a single-party regim.pdfNorth Korea Is a socialist state. The system is a single-party regim.pdf
North Korea Is a socialist state. The system is a single-party regim.pdf
 
Noel Arrold podr�a haber terminado en trigo. O en el sal�n de clases.pdf
Noel Arrold podr�a haber terminado en trigo. O en el sal�n de clases.pdfNoel Arrold podr�a haber terminado en trigo. O en el sal�n de clases.pdf
Noel Arrold podr�a haber terminado en trigo. O en el sal�n de clases.pdf
 
Nike vendiendo una l�nea de ropa para acompa�ar su producto principa.pdf
Nike vendiendo una l�nea de ropa para acompa�ar su producto principa.pdfNike vendiendo una l�nea de ropa para acompa�ar su producto principa.pdf
Nike vendiendo una l�nea de ropa para acompa�ar su producto principa.pdf
 
Ninna Banks is responsible for recording cash disbursements, prepari.pdf
Ninna Banks is responsible for recording cash disbursements, prepari.pdfNinna Banks is responsible for recording cash disbursements, prepari.pdf
Ninna Banks is responsible for recording cash disbursements, prepari.pdf
 
Nike Case StudyDoes Jeff Ballinger have a convincing argument abo.pdf
Nike Case StudyDoes Jeff Ballinger have a convincing argument abo.pdfNike Case StudyDoes Jeff Ballinger have a convincing argument abo.pdf
Nike Case StudyDoes Jeff Ballinger have a convincing argument abo.pdf
 
NIIF 9 instrumento financiero permite el uso de contabilidad de cobe.pdf
NIIF 9 instrumento financiero permite el uso de contabilidad de cobe.pdfNIIF 9 instrumento financiero permite el uso de contabilidad de cobe.pdf
NIIF 9 instrumento financiero permite el uso de contabilidad de cobe.pdf
 
Nicholas is currently in eighth grade and intends to attend a state .pdf
Nicholas is currently in eighth grade and intends to attend a state .pdfNicholas is currently in eighth grade and intends to attend a state .pdf
Nicholas is currently in eighth grade and intends to attend a state .pdf
 
NetworkingShow the commandsUsing nmcli , create a new network .pdf
NetworkingShow the commandsUsing nmcli , create a new network .pdfNetworkingShow the commandsUsing nmcli , create a new network .pdf
NetworkingShow the commandsUsing nmcli , create a new network .pdf
 
Network Environment & Configuration Requirements You are a support t.pdf
Network Environment & Configuration Requirements You are a support t.pdfNetwork Environment & Configuration Requirements You are a support t.pdf
Network Environment & Configuration Requirements You are a support t.pdf
 

Recently uploaded

Employablity presentation and Future Career Plan.pptx
Employablity presentation and Future Career Plan.pptxEmployablity presentation and Future Career Plan.pptx
Employablity presentation and Future Career Plan.pptxryandux83rd
 
Congestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationCongestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationdeepaannamalai16
 
Comparative Literature in India by Amiya dev.pptx
Comparative Literature in India by Amiya dev.pptxComparative Literature in India by Amiya dev.pptx
Comparative Literature in India by Amiya dev.pptxAvaniJani1
 
The role of Geography in climate education: science and active citizenship
The role of Geography in climate education: science and active citizenshipThe role of Geography in climate education: science and active citizenship
The role of Geography in climate education: science and active citizenshipKarl Donert
 
Shark introduction Morphology and its behaviour characteristics
Shark introduction Morphology and its behaviour characteristicsShark introduction Morphology and its behaviour characteristics
Shark introduction Morphology and its behaviour characteristicsArubSultan
 
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...Nguyen Thanh Tu Collection
 
Indexing Structures in Database Management system.pdf
Indexing Structures in Database Management system.pdfIndexing Structures in Database Management system.pdf
Indexing Structures in Database Management system.pdfChristalin Nelson
 
ICS 2208 Lecture Slide Notes for Topic 6
ICS 2208 Lecture Slide Notes for Topic 6ICS 2208 Lecture Slide Notes for Topic 6
ICS 2208 Lecture Slide Notes for Topic 6Vanessa Camilleri
 
Narcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdfNarcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdfPrerana Jadhav
 
Mythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITWMythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITWQuiz Club NITW
 
DBMSArchitecture_QueryProcessingandOptimization.pdf
DBMSArchitecture_QueryProcessingandOptimization.pdfDBMSArchitecture_QueryProcessingandOptimization.pdf
DBMSArchitecture_QueryProcessingandOptimization.pdfChristalin Nelson
 
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...Association for Project Management
 
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptxBIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptxSayali Powar
 
4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptx4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptxmary850239
 
DiskStorage_BasicFileStructuresandHashing.pdf
DiskStorage_BasicFileStructuresandHashing.pdfDiskStorage_BasicFileStructuresandHashing.pdf
DiskStorage_BasicFileStructuresandHashing.pdfChristalin Nelson
 

Recently uploaded (20)

Employablity presentation and Future Career Plan.pptx
Employablity presentation and Future Career Plan.pptxEmployablity presentation and Future Career Plan.pptx
Employablity presentation and Future Career Plan.pptx
 
Congestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationCongestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentation
 
Comparative Literature in India by Amiya dev.pptx
Comparative Literature in India by Amiya dev.pptxComparative Literature in India by Amiya dev.pptx
Comparative Literature in India by Amiya dev.pptx
 
The role of Geography in climate education: science and active citizenship
The role of Geography in climate education: science and active citizenshipThe role of Geography in climate education: science and active citizenship
The role of Geography in climate education: science and active citizenship
 
Paradigm shift in nursing research by RS MEHTA
Paradigm shift in nursing research by RS MEHTAParadigm shift in nursing research by RS MEHTA
Paradigm shift in nursing research by RS MEHTA
 
Plagiarism,forms,understand about plagiarism,avoid plagiarism,key significanc...
Plagiarism,forms,understand about plagiarism,avoid plagiarism,key significanc...Plagiarism,forms,understand about plagiarism,avoid plagiarism,key significanc...
Plagiarism,forms,understand about plagiarism,avoid plagiarism,key significanc...
 
Shark introduction Morphology and its behaviour characteristics
Shark introduction Morphology and its behaviour characteristicsShark introduction Morphology and its behaviour characteristics
Shark introduction Morphology and its behaviour characteristics
 
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
 
Indexing Structures in Database Management system.pdf
Indexing Structures in Database Management system.pdfIndexing Structures in Database Management system.pdf
Indexing Structures in Database Management system.pdf
 
ICS 2208 Lecture Slide Notes for Topic 6
ICS 2208 Lecture Slide Notes for Topic 6ICS 2208 Lecture Slide Notes for Topic 6
ICS 2208 Lecture Slide Notes for Topic 6
 
Narcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdfNarcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdf
 
Faculty Profile prashantha K EEE dept Sri Sairam college of Engineering
Faculty Profile prashantha K EEE dept Sri Sairam college of EngineeringFaculty Profile prashantha K EEE dept Sri Sairam college of Engineering
Faculty Profile prashantha K EEE dept Sri Sairam college of Engineering
 
Mythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITWMythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITW
 
DBMSArchitecture_QueryProcessingandOptimization.pdf
DBMSArchitecture_QueryProcessingandOptimization.pdfDBMSArchitecture_QueryProcessingandOptimization.pdf
DBMSArchitecture_QueryProcessingandOptimization.pdf
 
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
 
Introduction to Research ,Need for research, Need for design of Experiments, ...
Introduction to Research ,Need for research, Need for design of Experiments, ...Introduction to Research ,Need for research, Need for design of Experiments, ...
Introduction to Research ,Need for research, Need for design of Experiments, ...
 
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptxBIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
 
4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptx4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptx
 
prashanth updated resume 2024 for Teaching Profession
prashanth updated resume 2024 for Teaching Professionprashanth updated resume 2024 for Teaching Profession
prashanth updated resume 2024 for Teaching Profession
 
DiskStorage_BasicFileStructuresandHashing.pdf
DiskStorage_BasicFileStructuresandHashing.pdfDiskStorage_BasicFileStructuresandHashing.pdf
DiskStorage_BasicFileStructuresandHashing.pdf
 

namespace Habib_OLA4 { internal class Program { .pdf

  • 1. namespace Habib_OLA4 { internal class Program { private int[] digits; public BigNumber() { digits = new int[40]; } public void Input(string input) { int startIndex = 0; bool isNegative = false; if (input[0] == '-') { isNegative = true; startIndex = 1; } for (int i = 0; i < digits.Length; i++) { digits[i] = 0; } for (int i = startIndex; i < input.Length; i++) { digits[digits.Length - input.Length + i] = input[i] - '0'; } if (isNegative) { Negate(); } } public override string ToString() { int startIndex = 0; while (startIndex < digits.Length - 1 && digits[startIndex] == 0)
  • 2. { startIndex++; } if (digits[startIndex] < 0) { return "-" + new BigNumber(digits).ToString(); } char[] chars = new char[digits.Length - startIndex]; for (int i = 0; i < chars.Length; i++) { chars[i] = (char)(digits[startIndex + i] + '0'); } return new string(chars); } public BigNumber Add(BigNumber other) { BigNumber result = new BigNumber(); int carry = 0; for (int i = digits.Length - 1; i >= 0; i--) { int sum = digits[i] + other.digits[i] + carry; result.digits[i] = sum % 10; carry = sum / 10; } return result; } public BigNumber Subtract(BigNumber other) { BigNumber result = new BigNumber(); int borrow = 0; for (int i = digits.Length - 1; i >= 0; i--) { int difference = digits[i] - other.digits[i] - borrow; if (difference < 0) { difference += 10;
  • 3. borrow = 1; } else { borrow = 0; } result.digits[i] = difference; } return result; } public bool IsEqualTo(BigNumber other) { for (int i = 0; i < digits.Length; i++) { if (digits[i] != other.digits[i]) { return false; } } return true; } public bool IsNotEqualTo(BigNumber other) { return !IsEqualTo(other); } public bool IsGreaterThan(BigNumber other) { for (int i = 0; i < digits.Length; i++) { if (digits[i] > other.digits[i]) { return true; } else if (digits[i] < other.digits[i]) { return false;
  • 4. } } return false; } public bool IsLessThan(BigNumber other) { for (int i = 0; i < digits.Length; i++) { if (digits[i] < other.digits[i]) { return true; } else if (digits[i] > other.digits[i]) { return false; } } return false; } public bool IsGreaterThanOrEqualTo(BigNumber other) { for (int i = 0; i > digits.Length; i++) { if (digits[i] > other.digits[i]) { return true; } else if (digits[i] < other.digits[i]) { return false; } } return false; } public static void Main(string[] args) {
  • 5. BigNumber integer1 = new BigNumber(); BigNumber integer2 = new BigNumber(); Console.Write("Enter first BigNumber: "); integer1.Input(Console.ReadLine()); Console.Write("Enter second BigNumber: "); integer2.Input(Console.ReadLine()); Console.WriteLine($"BigNumber 1: {integer1}"); Console.WriteLine($"BigNumber 2: {integer2}"); BigNumber result; // add two BigNumbers result = integer1.Add(integer2); Console.WriteLine($"Add result: {result}"); // subtract two BigNumbers result = integer1.Subtract(integer2); Console.WriteLine($"Subtract result: {result}"); // compare two BigNumbers Console.WriteLine($"BigNumber 1 is zero: {integer1.IsZero()}"); Console.WriteLine($"BigNumber 2 is zero: {integer2.IsZero()}"); Console.WriteLine($"BigNumber 1 is equal to BigNumber 2: {integer1.IsEqualTo(integer2)}"); Console.WriteLine($"BigNumber 1 is not equal to BigNumber 2: {integer1.IsNotEqualTo(integer2)}"); Console.WriteLine($"BigNumber 1 is greater than BigNumber 2: {integer1.IsGreaterThan(integer2)}"); Console.WriteLine($"BigNumber 1 is less than BigNumber 2: {integer1.IsLessThan(integer2)}"); Console.WriteLine($"BigNumber 1 is greater than or equal to BigNumber 2: {integer1.IsGreaterThanOrEqualTo(integer2)}"); Console.WriteLine($"BigNumber 1 is less than or equal to BigNumber 2: {integer1.IsLessThanOrEqualTo(integer2)}"); } } } I have an error.
  • 6. //This what the output support to look like Sample Run 1: Enter first BigNumber: 1234567890123456789012345678901234567890 Enter second BigNumber: 0987654321098765432109876543210987654321 BigNumber 1: 1234567890123456789012345678901234567890 BigNumber 2: 987654321098765432109876543210987654321 Add result: 2222222211222222221122222222112222222211 Subtract result: 246913569024691356902469135690246913569 BigNumber 1 is zero: False BigNumber 2 is zero: False BigNumber 1 is equal to BigNumber 2: False BigNumber 1 is not equal to BigNumber 2: True BigNumber 1 is greater than BigNumber 2: True BigNumber 1 is less than BigNumber 2: False BigNumber 1 is greater than or equal to BigNumber 2: True BigNumber 1 is less than or equal to BigNumber 2: False Press any key to continue . . . Can you help me with the c# program?