Sum of Two Prime Numbers – C++ program

Write a program in C++ to Check Whether a Number can be Express as a Sum of Two Prime Numbers.

Prime Number C++

Prime Number Program for Positive Numbers

This is the prime Number Program for Positive Numbers, if the user enter a negative number then the program asks the user, again and again, to enter the positive number, until the user enters the positive number.

Prime Number Program for Positive Numbers in C++

Output

Prime Number Program for Positive Numbers in C++

Flowchart of Sum of Two Prime Numbers – C++ program

Flowchart of Sum of Two Prime Numbers Program in C++

C++ program of Sum of Two Prime Numbers

Output

Enter a +ve Integer: 4

4 = 3+1

Excercise

Find the possible mistakes in the following Shamil’s Flow Table of the program of  Sum of Two Prime Numbers in C++.

Loop 1 Loop 2 Loop

 3

If 1 if 2 if 3 If 4 What line will execute
1 time

i=3;

j=2 j=2

j=3;

j=4

j=5

j=6

 

False false True False 1,2,3,4,5,6,7,8,9,10,11,12,

13,14,15,16,17,

22,23,24,25,30,31,32,(23,24,25,

26,27,28,29,30,31,32)4,33,34,35

,36,37,38,39,40,41,42,43,44,48

2 time

I=4

j=2

j=3

 

J=2

J=3

J=4

J=5

True True False True 1,2,3,4,5,6,7,8,9,10,11,12,13,

14,15,16,17,22,23,24,25,30,

31,32,(23,24,25,

26,27,28,29,30,31,32)4,33,

34,35,36,37,38,39,40,41,

42,43,

10,11,12,13,14,15,16,17,

18,19,20,21,22,(23,24,25,26,

27,28,29,30,31,32)2

,(23,24,25,30,31,32,)2,33,38,

39,40,15,16,17,22,23,24,25,

26,27,28,29,30

,31,32,(23,24,25,30,31,32,)2,

32,33,38,39,40,41,42,

43,44,45,46,47,48

 

3 time

I=5;

J=2 J=2 False False True False 1,2,3,4,5,6,7,8,9,10,11,

12,13,14,15,16,17,22,23,

24,25,30,31,32, (23,24,25,

26,27,28,29,30,31,32)4,

33,34,35,36,37,38,39,

40,41,42,43,

10,11,12,13,14,15,16,

17,18,19,20,21,22,

(23,24,25,26,27,28,29,30,31,32)2

, (23,24,25,30,31,32,)2,

33,38,39,40,15,16,17,22,

23,24,25,26,27,28,29,30

,31,32, (23,24,25,30,31,32,)2,

32,33,38,39,40,41,42,43,

10,11,12,13,14,15,16,17,22,

(23,24,25,26,27,28,29,30,31,32)3,

33,34,35,36,

37,38,39,40, 15,16,17,22,

(23,24,25,26,27,28,29,30,31,32)2,

33,34,35,36,

37,38,39,40, 15,16,17,22, 23,

24,25,26,27,28,29,30,31,32,

33,34,35,36,

37,38,39,40,41,42,43,44,48,

 

 

 

 

Latest posts by Prof. Fazal Rehman Shamil (see all)

Buy advertisement space on T4Tutorials

For more details email [email protected]