SlideShare una empresa de Scribd logo
1 de 6
Descargar para leer sin conexión
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?

Más contenido relacionado

Similar a 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 a 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
 

Más de 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
 

Más de 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
 

Último

social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
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
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
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
 

Último (20)

social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.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
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
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
 

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?