We are here with you hands in hands to facilitate your learning & don't appreciate the idea of copying or replicating solutions. Read More>>


Looking For Something at vustudents.ning.com? Click Here to Search

Assignment Question :

You are required to write a program in C# programming language which will get a numeric value from user and show two prime numbers whose addition is equal to the number entered by user. You need to show all combination of prime numbers.

 

Assignment Instructions:

  • Find two prime numbers whose addition will be equal to user entered number.
  • Find all possible combinations of prime number whose addition will be equal to number entered by user. 

Hints:

To make the solution easily first you need to understand the problem with an example.

  • Suppose user entered the number 36. So you have N = 36.
  • Iterate from 2 to N/2 and find a prime number. Subtract the prime number from 36, if remaining is also prime number then you found two prime numbers whose sum is equal to user’s entered number. You can see its working in Sample Output video.
  • isPrime(n) method you created in Assignment no. 3 will help you to check a number is prime or not. Just you need to change it from Java to C# syntax.

Sample Output:

For sample output watch Sample Output video file.

 

Assignment Submission Instructions:

If you do not have Microsoft Visual Studio to make program in C# then use online tool given on http://volatileread.com/UtilityLibrary/SnippetCompiler

The procedure to use online tool is showing in Sample Output video file.

Please note that due date of assignment will not extend, so do not wait for last date and submit your solution as quickly as possible.

Due Date: Tuesday, February 06, 2017.

Share This With Friends......

+ Click Here To Join also Our facebook study Group.

This Content Originally Published by a member of VU Students.

+ Prohibited Content On Site + Report a violation + Report an Issue


..How to Join Subject Study Groups & Get Helping Material?..


Views: 2403

See Your Saved Posts Timeline

Replies to This Discussion

Here is My Solution 
share your solution

ammar bhai is ka code send kryn aysy to nzr e nai aa raha hay.

code to itny logo ne share kr dia :)

using System;
using System.Collections.Generic;
using System.Linq;

public class Program
{
public static void Main()
{
Program obj = new Program();

string number;

Console.WriteLine("Enter a positive number:");
number = Console.ReadLine();
double Number = Convert.ToDouble(number);

double result = Number/2;

double num1,second,final;

bool flag=false;

for(double i=2; i<=result; i++){ if(obj.isprimenumber(i)){ num1 = Number-i; if(obj.isprimenumber(num1)){ Console.WriteLine(num1+" + "+i+" = "+Number); flag = true; } } } if(flag){ Console.Write("All combinations found."); }else{ Console.Write(Number+" can not be expressed as the sum of two prime numbers."); } } public bool isprimenumber(double num){ for (int i = 2; i <= num / 2; i++) { if (num % i == 0) { return false; } return true; } return false; } } http://volatileread.com/utilitylibrary/snippetcompiler?id=104572

ye ghalat hy

to bhai ap theek wala share kr k dikha do

Program obj = new Program();
string number;
Console.WriteLine("Enter a positive number:");
number = Console.ReadLine();
double Number = Convert.ToDouble(number);
double result = Number/2;
double num1;
bool flag=false;
for(double i=2; i<=result; i++)

if(obj.isprimenumber(i))
{ num1 = Number-i; if(obj.isprimenumber(num1))
{ Console.WriteLine(num1+" + "+i+" = "+Number); 
flag = true; } } } if(flag)
{ Console.Write("All combinations found.");
Console.ReadKey();
}
else
{ Console.Write(Number+" can not be expressed as the sum of two prime numbers.");
Console.ReadKey();
}
Console.WriteLine("Enter a positive number:");
number = Console.ReadLine();

ye bhi ghalat hy

Abrar Ahmed (BSSE) plz share correct solution if you did

Please Discuss here about this assignment.Thanks

Our main purpose here discussion not just Solution

We are here with you hands in hands to facilitate your learning and do not appreciate the idea of copying or replicating solutions. Read More>>

 

Note:-

For Important Helping Material related to this subject (Solved MCQs, Short Notes, Solved past Papers, E-Books, FAQ,Short Questions Answers & more). You must view all the featured Discussion in this subject group.

For how you can view all the Featured discussions click on the Back to Subject Name Discussions link below the title of this Discussion & then under featured Discussion corner click on the view all link.

Or visit this link 

Click Here For Detail.

&

.•°How to Download past papers from study groups°•.

 

Please Click on the below link to see…

.... How to Find Your Subject Study Group & Join .... 

please help me 

out put main sum mix a raha hai.

odd aur prime. likin prime akaila nahin aaraha hai

how i manage it. thanks

RSS

© 2019   Created by + M.Tariq Malik.   Powered by

Promote Us  |  Report an Issue  |  Privacy Policy  |  Terms of Service