Sum-of-product and product-of-sum in c#
how programmer Sum-Of-Products & Product-Of-Sums by c#
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Kirtan PatelRank #292 · 8.6K reputationPosted Nov 29, 2009, 7:56 AM EST
Here is Constructed Logic for Sum of Product For 3 bit ( 8 Combination) 3 FlipFlops
if my answer helps you then check "do you like this answer check box" please :)
using System.Collections.Generic;
{
class Program
{
static void Main(string[] args)
{
Dictionary<string, int> BinaryAndOutput = new Dictionary<string, int>();
//Construct Binary table 000 001 010 011 100 etc and Store In Dictionary
//Construct Binary counts and Assign Output to Each Count
for (int x = 0; x <= 1; x++)
{
for (int y = 0; y <= 1; y++)
{
for (int z = 0; z <= 1; z++)
{
string binary = x.ToString() + y.ToString() + z.ToString();
Console.WriteLine("Enter Desire Output for " + binary + ":");
int value = int.Parse(Console.ReadLine());
BinaryAndOutput.Add(binary,value);
}
}
}
//Construct SOP
string sop = "";
foreach (KeyValuePair<string,int> k in BinaryAndOutput)
{
char[] temp = k.Key.ToString().ToCharArray();
char var ='A';
if (k.Value == 1)
{
foreach (char c in temp)
{
if (c == '1')
{
sop = sop + var;
var++;
}
else
{
sop = sop + var + "'";
var++;
}
}
sop += "+";
}
}
Console.WriteLine("\n\n********** Sum of Product ************\n");
Console.WriteLine(sop);
Console.ReadKey();
}
}
}