TECHXCODE Under Construction

C++ Program to find factors of a number

- 0 Comments
/* Program to find factors of a number */

#include<iostream>
#include<conio.h>
int main()
{
    using namespace std;
    int no,flag = 1;
    cout<<"Enter the number\t";
    cin>>no;
    for(int i = 1; i < no/i; i++)
        if(no%i==0)
            cout<<i<<" * "<<no/i<<" = "<<no<<endl;
    getch();
    return 0;
}
[Continue reading...]

C++ Program to Check if number is prime or not

- 0 Comments
/* Program to Check if number is prime or not */

#include<iostream>
#include<conio.h>    //conio is used for getch
int main()
{
    using namespace std;
    int no,flag=0;
    cout<<"Enter the natural number\t";
    cin>>no;
    for(int i = 2; i < no/i; i++)           // prime number start with 2
    {
        if(no%i==0)                            //if prime number not exist
        {
            flag = 1;
            break;                       
        }
        else                                          // if prime number exist
            flag = 0;
    }
    if(flag == 1)
    cout<<no<<" is non prime number.";
    else
    cout<<no<<" is prime number.";
    getch();
    return 0;
}
[Continue reading...]

C++ Program to check if a number is even or odd

- 0 Comments
/* Program to check if a number is even or odd */

#include<iostream>
int main()
{
    using namespace std;
    int no;
    cout << "Enter the integer\t";
    cin >> no;
    if (no%2 == 0)                    //if no is divisible by 2, then no is even
    cout << no << " is even.";
    else
    cout << no << " is odd.";
    return 0;
}
[Continue reading...]

TECHXCODE ? Just a Random beginning

- 0 Comments
I don't have good idea to start this post. But am sure I will update this first post later. So, visit other posts of the website.
[Continue reading...]
 
Copyright © . TECHXCODE.COM - Posts · Comments
Theme Template by BTDesigner · Powered by Blogger