Showing posts with label find. Show all posts
Showing posts with label find. Show all posts

Wednesday, February 18, 2015

C program to find the sum of series 1 2 4 5 7 8

C program to find the sum of series 1/2+4/5+7/8+......

#include<stdio.h>
#include<conio.h>


void main()
{
int i,n;
clrscr();
float sum=0,x,a=1;

printf("1/2+4/5+7/8+......");
printf("

How many terms(ex: 1,2,3...n)?");
scanf("%d",&n);


for(i=0;i<n;++i)
{
x=a/(a+1);
sum+=x;
a+=3;
}

printf("
Sum=%f",sum);
getch();
}
Read more »

Sunday, February 15, 2015

Best Way to Easily Find and Remove Broken Links from your Website or Blog


Best Way to Easily Find and Remove Broken Links from your Website or Blog

What are Broken Links?

Broken links are the links which leads to a page that actually does not exist. When you publish any article on your blog than search engines like Google indexe it and add your article information to its database. After some days or months if you delete your previously published article than it is removed from your blog database but not from Google database. If anyone search for a keyword related to your article on Google than your article link come up in the search results. And if he/she clicks on the link then it leads to a 404 error page.

Also Read: The Top 10 Websites to create free Logo for your Blog

404 error pages and broken links have a negative effect on SEO and which decreases your search engine ranking. Let’s take an example to explain it more clearly. Suppose if you search for a keyword on Google, than so many search results come up. When you click one of them you may come across a 404 error page. Now tell me that, what you will do in this situation? You will immediately leave that site and go for another one. Google consider this as bad practice and which gradually leads to decrease in your search engine ranking.

In this post I am going to tell you the best way to easily find and remove broken links from your blog. This can be done by using an online tool Google Webmaster Tool. This is one of the tool that I occasionally use to detect and remove broken links from my blog. If you have a blogger blog then there is no need to register but if you have a wordpress blog then you have to first register your blog. Let’s see how to remove these useless links from Google database.

Also Read: Tips on How to Have Better SEO Results with Link Building

How to Find and Remove Broken Links?

1. First of all login to Google Webmaster Tool by going to the link given below:
            http://www.google.com/webmasters/
2. Now go to Dashboard and select the blog that you want (if you have more than one) from the drop down menu situated at right top.
3. Go to Health>Crawl Errors and than click on Not found option as shown below.

Best Way to Easily Find and Remove Broken Links from your Website or Blog
(click on the image to enlarge)

4. After that you will see a list of all the broke links in your blog. Than click on any link from the list, now a new pop-up window will open, copy the link from there.
5. Now go to Optimization>Remove URLs and than click on Create a new removal request, paste the link that you have copied earlier in the box as shown below and than click on Continue button.

Best Way to Easily Find and Remove Broken Links from your Website or Blog
(click on the image to enlarge)

6. A new window will open,there click on Submit Request as shown below.

Best Way to Easily Find and Remove Broken Links from your Website or Blog
(click on the image to enlarge)

7. After completing this process just mark all the links as fixed so that these links will be not listed in the Not found list, otherwise they may confuse you in future.
8. You have done…..! Do you have any query? You are free to ask, just comment below.

Note: Google webmaster Tool will take some time to remove these URLs from Google database.
Read more »

Saturday, February 14, 2015

Java Program to Find Intersection of two Arrays

For example we have two sorted arrays a1[]={2,3,5,11} and a2[]={4,5,7,9,11} then intersection of a1 and a2 will be {5,11}. A Java program for finding intersection of two arrays is given below.

Also Read: Java Program to Find Union of two Arrays

Java Program to Find Intersection of two Arrays

import java.util.Scanner; //import Scanner class in our program

class demo
{
public static void main(String...s)
{
int i,j,n1,n2;
Scanner sc=new Scanner(System.in); //used to read from keyboard

System.out.print("Enter number of elements of first array:");
n1=sc.nextInt();
System.out.print("Enter number of elements of second array:");
n2=sc.nextInt();

int a1[]=new int[n1];
int a2[]=new int[n2];

System.out.print("
Enter elements of first array in ascending order:");

for(i=0;i<n1;++i)
a1[i]=sc.nextInt();

System.out.print("
Enter elements of second array in ascending order:");

for(i=0;i<n2;++i)
a2[i]=sc.nextInt();


i=j=0;
System.out.print("
Intersection of Arrays: ");

while(i<n1&&j<n2)
{
if(a1[i]<a2[j])
i++;
else
if(a2[j]<a1[i])
j++;
else
{
System.out.print(a1[i]+" ");
i++;
j++;
}
}

}
}

Java Program to Find Intersection of two Arrays
Read more »

C program to find largest and second largest no from a 2D array

C++ program to find largest and second largest no from a 2D array

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

void main()
{
clrscr();
int a[5][5],big1,big2,n,m,i,j;
cout<<"Enter no of rows and columns(max 5):";
cin>>m>>n;
cout<<"Enter the array:
";

for(i=0;i<m;i++)
for(j=0;j<n;++j)
cin>>a[i][j];

big1=a[0][0];
for(i=0;i<m;++i)
for(j=0;j<n;++j)
{
if(a[i][j]>big1)
big1=a[i][j];
}

big2=a[0][0];
for(i=0;i<m;++i)
for(j=0;j<n;++j)
{
if(a[i][j]>big2&&a[i][j]<big1)
big2=a[i][j];
}

cout<<"

Largest number:"<<big1;

cout<<"
Second largest number:"<<big2;

getch();
}

Read more »

Friday, February 13, 2015

C Program to find Greatest number among three numbers

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

void main()
{
int x,y,z,max;
clrscr();
cout<<"Enter The Three Numbers ";
cin>>x>>y>>z;

max=x;
if (y>max)
max=y;
if (z>max)
max=z;

cout<<"
"<<"The Greatest Number among "<<x<<" "<<y<<" "<<z<<" is "<<max;

getch();
}

Read more »

Thursday, February 12, 2015

C Program to find quotient and remainder of two numbers


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


void main()
{
clrscr();
int a,b,q,r;
cout<<"Enter two numbers:";
cin>>a>>b;


if(a>b)
{
q=a/b;
r=a%b;
cout<<"
Quotient="<<q;

cout<<"
Remainder="<<r;

}
else
cout<<"
First no. should be greater than second no....!!!";



getch();
}

Read more »

Wednesday, February 11, 2015

C C Program to Find Substring in String Pattern Matching

Pattern matching refers to find the position where a string pattern appears in a given string. If the requird string is not present in given text, then it returns the value zero.

If the required string is present in a given string, it returns the position of occurrence of required string or substring.

Also Read: C program to concatenate two strings without using strcat() function


C Program


#include<stdio.h>

int main()
{
int i,j,temp;
char str[100]={"This is a pattern matching"};
char substr[20]={"pattern"};

for(i=0;str[i]!=
Read more »

C program to find length of a string


C program to find length of a string

#include<stdio.h>
#include<conio.h>

void main()
{
int i;
char str[50];
clrscr();
printf("Enter a string:");
gets(str);

for(i=0;str[i]!=
Read more »

Wednesday, February 4, 2015

How to find the Greatest common divisor of an integer array in java

In this post Im going to illustrate very simple algorithm to find the Greatest Common Divisor (GCD)  of set of integers (an array) using java.

  • In this algorithm we first find the smallest integer in the int array. 
  • Then we get the modulus for each element in the numbers of the array by dividing smallest integer and add all those modulus together. 
  • After processing each element in the array we check if the total of modulus is equals to 0.  If it is equal to 0 then the GCD is  current smallest value if that total is not equals 0 we deduct 1 from the previous smallest value and do the same computation. 
  • The algorithm will continue with  the same operations until total of modulus becomes 0 or until smallest integer is 2.
  • If there is any GCD, algorithm will return it or otherwise it will return -1.

See the following implementation of the algorithm.


public class GCD {

public static int findGcd(int... numbers) {

//Find the smallest integer in the number list

int smallest = numbers[0];

for (int i = 1; i < numbers.length; i++) {
if (numbers[i] < smallest) {
smallest = numbers[i];
}
}

//Find the GCD
while (smallest > 1) {

int counter = 0;
int modTot = 0;

while (counter < numbers.length) {

modTot += numbers[counter] % smallest;
counter++;

}

if (modTot == 0) {
//Return the gcd if any
return smallest;
}

//System.out.print(" "+ smallest);
smallest--;

}
//return -1 if there is no gcd
return -1;
}

public static void main(String[] x) {
System.out.println("The GCD of 15 18 42 108 : "+GCD.findGcd(new int[]{15, 18, 42,108}));
}
}

Here is the output for 15, 18, 42 and 108


Here is the output for 3,7 and 12



Read more »