# Memeriksa Nomor sebagai Jumlah dari Dua Angka Utama C++

Pada kesempatan kali ini Mycoding.net akan mengulas tentang , dengan judul artikel Memeriksa Nomor sebagai Jumlah dari Dua Angka Utama C++.

##### Artikel Terkait Tutorial C
To understand this example, you should have knowledge of following C++ programming topics:
This program takes a positive integer from user and checks whether that number can be expressed as the sum of two prime numbers. If that number can be expressed as sum of two prime numbers then, that number is expressed as sum of two prime numbers in output. To perform this task, a user-defined function is created to check prime number
Tag : Examples C++ Objects and Class, C++ Constructors Tutorials, Coding C++ Objects & Function, Program C++ Operator Overloading

``#include <iostream>using namespace std;int check_prime(int n);int main(){    int n, i, flag=0;    cout << "Enter a positive  integer: ";    cin >> n;    for(i=2; i<=n/2; ++i)    {        if (check_prime(i)==0)        {            if ( check_prime(n-i)==0)            {                cout << n << " = " << i << " + " << n-i << endl;                flag=1;            }        }    }    if (flag==0)      cout << n << " can't be expressed as sum of two prime numbers.";    return 0;}int check_prime(int n) /*check prime number*/{  int i, flag=0;  for(i=2;i<=n/2;++i)  {      if(n%i==0)      {          flag=1;          break;      }  }  return flag;}``

Output
`Enter a positive integer: 3434 = 3 + 3134 = 5 + 2934 = 11 + 2334 = 17 + 17`

Selain Sebagai Penyedia Panduan Belajar Database dan Tutorial Pemrograman, Kami Juga Membagikan Kumpulan Source Code Program Aplikasi dan Ebook Pemrograman Terlengkap yang Bisa Anda Dapatkan Secara Gratis di Halaman :

##### Rekomendasi Web Hosting
Hosting murah minimal order 1 bulan cuma 20rb. Gunakan voucher diskon 20%, kode voucher: MCPROJECT, total bayar hanya 16rb!!! Daftar sekarang