Új hozzászólás Aktív témák

  • Lejszi

    senior tag

    Sziasztok! Csak kost kezdek ismerkedni a c++ nyelvvel. Miert nem akar mukodni a progi?
    Tudna vki segiteni? Mit rontottal el? Koszonom.

    #include "stdafx.h"
    #include <iostream>
    #include <conio.h>
    using namespace std;

    int main()

    {
    int a, b;
    cout << "Please enter the first number: ";
    cin >> a;
    cout << "Please enter the second number: ";
    cin >> b;
    cout << "sum is " << a + b << "\n";

    int n, i, flag = 0;
    cout << "Enter a positive integer: ";
    cin >> n;
    for (i = 2; i <= n / 2; ++i)
    {
    if (n&i == 0)
    {
    flag = 1;
    break;
    }
    }
    if (flag == 0)
    cout << "This is a prime numer";
    else
    cout << "This is not a prime number";
    _getch();

    return 0;
    }

    update:
    megvan! % kellett volna hasznalnom a & helyett.
    Silly me :))

    [ Szerkesztve ]

Új hozzászólás Aktív témák