Pages

Showing posts with label class c. Show all posts
Showing posts with label class c. Show all posts

Thursday, November 12, 2015

C++ Program to Find Prime Number Or Not

This c++ program checks if a number is a prime or not. A number which is greater than 1 and can only be divided by 1 and itself are prime numbers. These prime numbers include 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31 and so on. A FOR loop is implemented in this program. If the number entered by the user can be divided by another number that is within its range to give zero as the remainder then, this number is not a prime number.


#include <iostream.h>
#include <math.h>
void main()
{
int num, a=0;
cout<<"enter a number: ";
cin>>num;
for(int i=2;i<num;i++)//loop begins at 2 since 1 can divide any number
{
if(num%i==0)
{
a++;
}
}
if(a==0)
{
cout<<num<<" is a prime number";
}
else
cout<<num<<"is not a prime";
}
Read more »

Wednesday, November 11, 2015

C++ Program to Compute The Least Common Multiple of Integers

C++ program to compute the LCM of two numbers. Least Common Multiple can be gotten by dividing the numbers by their common factors.Using the logic below, we can also find write a program to calculate the LCM for more numbers.

//C++ program that computes the least common multiple of two integers. These are represented as a and b below.

#include<iostream.h>
#include<conio.h>
void main()
{
int a,b,i,j; //Variable declarations
clrscr;
cout<<"enter a number: ";
cin>>a;
cout<<"enter a number: ";
cin>>b;
i=a ;
j=b;
if(a==0||b==0) //Checks if either a OR b is 0
cout<<" The LCM is 0"; //If 0 from the condition above, a display message is output to the screen
else
{
while(a!=b)//While the value of a is not equal to b execute the statements below
{
if(a>b)
b=b+j;
else
if(a<b)
a=a+i;
}
cout<<"LCM:"<<" "<<a;
}
}
Read more »

C++ Program to Compare The Greatest Of Three Integers

C++ program to compare which is the greatest among three numbers. An IF statement is used to set the condition to know which is less or greater than which.

#include<iostream.h>
#include<math.h>
#include<conio.h>
void main()
{
int a,b,c;
clrscr();
cout<<"enter the first value";
cin>>a;
cout<<"enter the second value";
cin>>b;
cout<<"enter the third value";
cin>>c;
if (a>b&&b>c)
cout<<"The greatest is: "<<a;
else
if(a<b&&b>c)
cout<<"The greatest is: "<<b;
else
if(a<b&&b<c)
cout<<"The greatest is: "<<c;
else
if(a==b&&b==c)
cout<<"Non is greater!!";
}
Read more »

Friday, November 6, 2015

How to Share Blogger Post Automatically to Social Networks

Sharing blogger post automatically to best social networking sites like facebook, and twitter can help bring meaningful traffic to your blog depending on your fan size. The more the fans, the more page views for you. With the steps below, your post on blogger will be sent automatically to your facebook page instead of sharing them manually each time you update your blog. Should make blogging easier for you and help in efficient use of your time. Twitterfeed and dlvr can be used to share your blog post to social networks.

Also Read: How To Add Floating Share Buttons On Blogger

How to Share Blogger Post to Social Networks with twitterfeed


1. Goto  twitterfeed and create a new account if you don't have one already.

2. Click On 'create new feed'.

3. Enter feed name (your desired name)  and your URL  in the spaces provided. Then click on 'continue'.

 

3. Click on 'connect a service', select facebook or twitter depending on which social network you want to share your blog post to.


4. Authenticate your facebook or twitter accounts, then select 'create service'.



5. If the service you selected was facebook then continue, Choose facebook page or select facebook profile to share your blogger post on your facebook profile.

6. You can edit the number of times you want your post to be sent to your facebook page by clicking edit (optional), then advanced settings on twitterfeed. Save when your'e through.

Also Read: Social Media Follow And Subscription Follow Gadget For Blogger

How To Share Blogger Post To Social Networks Using Dlvr

1. Goto dlvr.

2. Signup for a new account or sign in if your'e a registered user.

3. Link your accounts.
Read more »