Coding in c++

in #coding9 years ago

Hy guys:what's up.
today i wrote 3 program & share with you i hope you trying to learn this programe.

(1) Enter the number & check it is prime number or not:

here is the program:

#include <iostream.h>
using namespace std;

main()
{
int n, i;
bool isPrime = true;

cout << "Enter a positive integer: ";
cin >> n;

for(i = 2; i <= n / 2; ++i)
{
if(n % i == 0)
{
isPrime = false;
break;
}
}
if (isPrime)
cout << " prime number";
else
cout << "not a prime number";

return 0;

}

(2) Program to Find Sum of an Array:

here is the programe
include<iostream.h>
#include<conio.h>

void main()
{
int arr[20],i,n,sum=0;
clrscr();
cout<<"How many elements you want to enter: ";
cin>>n;
cout<<"Enter any "<<n<<" elements in Array: ";
for(i=0;i<n;i++)
{
cin>>arr[i];
}
cout<<"Sum of all Elements are: ";

for(i=0;i<n;i++)
{
sum=sum+arr[i];
}
for(i=0;i<n;i++)
{
}
cout<<sum;
getch();
}

(3) Find Largest Number among three numbers:

here is the programe:

#include<conio.h>
#include<iostream.h>

void main()
{
clrscr();
int a, b, c;
cout <<"Enter any three numbers: ";
cin>>a;
cin>>b
cin>>c;
if(a>=b && a>=c)
{
cout<<"Largest number: "<<a;
}
if(b>=a && b>=c)
{
cout<<"Largest number: "<<b;
}
if(c>=a && c>=b)
{
cout<<"Largest number: "<<c;
}
getch();
}

i hope you like this:
thanks:dev-c-IDE-best-ide-list.png

Sort:  

This post has received a 0.72 % upvote from @boomerang thanks to: @iwant

@boomerang distributes 100% of the SBD and up to 80% of the Curation Rewards to STEEM POWER Delegators. If you want to bid for votes or want to delegate SP please read the @boomerang whitepaper.

I have been wanting to Learn C++ for a while. Im going to take a course because of you! Resteemed, Followed and 100% upvoted (>")>

c++ is a biggest language & i really enjoy to learn c++

wow..its a great post..keep it up

Coin Marketplace

STEEM 0.05
TRX 0.33
JST 0.080
BTC 63676.30
ETH 1681.71
USDT 1.00
SBD 0.41