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


+ Link For Assignments, GDBs & Online Quizzes Solution


+ Link For Past Papers, Solved MCQs, Short Notes & More

Dear Students! Share your Assignments / GDBs / Quizzes files as you receive in your LMS, So it can be discussed/solved timely. Add Discussion

How to Add New Discussion in Study Group ? Step By Step Guide Click Here.

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. 


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.

+ How to Follow the New Added Discussions at Your Mail Address?

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

+ How to become Top Reputation, Angels, Intellectual, Featured Members & Moderators?

+ VU Students Reserves The Right to Delete Your Profile, If?

See Your Saved Posts Timeline

Views: 2446


+ http://bit.ly/vucodes (Link for Assignments, GDBs & Online Quizzes Solution)

+ http://bit.ly/papersvu (Link for Past Papers, Solved MCQs, Short Notes & More)

+ Click Here to Search (Looking For something at vustudents.ning.com?)

+ Click Here To Join (Our facebook study Group)

Replies to This Discussion

Share Solution dosto

Thank God i have done....


Thank u so much Malik Sohail..

Malik bhai aap ke code main aik error hai

video main 31 dene se us ka answer 2+29 ata hai lakin aap ka to usy exoress hi ni krta......... main ne pic lagayi hai dekh ly


1 wala vu wali video ki pic hai 2 wali aap ka code run kiya hai..
is ka solve ker de

just change i=3 with i=2 in for loop in this portion

Console.Write("Input a positive integer: ");
n = Convert.ToInt32(Console.ReadLine());
for(i=3; i<=n/2; i++) you will find solution

using System;
using System.Collections.Generic;
using System.Linq;
public class assignment_4_Solution
public static void Main()
int n, i, flg1=1,flg2=1,flg3=0,j;

Console.Write("Enter a positive integer: ");
n = Convert.ToInt32(Console.ReadLine());
for(i=3; i<=n/2; i++)
/*---------- check for prime---------------*/
for(j=2; j<i; j++)
{ flg1=0;j=i;}
for(j=2; j<n-i; j++)
{ flg2=0;j=n-i;}
if(flg1==1 && flg2==1)
{ Console.Write("{1} + {2} = {0} \n",n,i,n-i);
{Console.Write("{0} can not be expressed as sum of two prime numbers.\n\n",n);}


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

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