ProgrmIt

A blog to help students to learn programming in various languages including C, C++, Java, Python and many more.

Subscribe For Free Latest Updates!

We'll not spam mate! We promise.

Sunday, 10 July 2016


 In mathematics, the Fibonacci numbers or Fibonacci sequence are the numbers in the following integer sequence:

01, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144.....

The Fibonacci spiral: an approximation of the golden spiral created by drawing circular arcs connecting the opposite corners of squares in the Fibonacci tiling; this one uses squares of sizes 1, 1, 2, 3, 5, 8, 13, 21, and 34.
By definition, the first two numbers in the Fibonacci sequence are either 1 and 1, or 0 and 1, depending on the chosen starting point of the sequence, and each subsequent number is the sum of the previous two. 
Information source: wikipedia.org


Program:->

Program Output
Output

def fibo( x ):
    f = -1; s = 1
    for i in range(0,x):
        n = f + s
        f = s
        s = n
        print n
    return;
n = input ("Enter the total elements in the series: ")
print "The Fibonacci series is: "
fibo(n)
Read More >>

Saturday, 9 July 2016


  In mathematics, the Fibonacci numbers or Fibonacci sequence are the numbers in the following integer sequence:

01, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144.....

The Fibonacci spiral: an approximation of the golden spiral created by drawing circular arcs connecting the opposite corners of squares in the Fibonacci tiling; this one uses squares of sizes 1, 1, 2, 3, 5, 8, 13, 21, and 34.
By definition, the first two numbers in the Fibonacci sequence are either 1 and 1, or 0 and 1, depending on the chosen starting point of the sequence, and each subsequent number is the sum of the previous two. 
Information source: wikipedia.org


Program:->
Program Output
Output


import java.util.Scanner;
public class seFibo {
    public static int fibo(int x) {
        int f = -1, s = 1, n;
        for (int i = 0; i < x; ++i) {
            n = f + s;
            f = s;
            s = n;
            System.out.println( n );
        }
        return (0);
    }
    public static void main(String[] args) {
        int n, i;
        Scanner sc = new Scanner (System.in);
        System.out.print("Enter the total elements in the series: ");
        n = sc.nextInt();
        System.out.println("The Fibonacci series is: ");
        fibo(n);
    }
}

Note: The program must be saved with name "SeFibo.java". 
Read More >>

Friday, 8 July 2016


In mathematics, the factorial of a non-negative integer n, denoted by n!, is the product of all positive integers less than or equal to n. For example,

5! = 5  *  4  *  3  *  2  * 1 = 120.
The value of 0! is 1, according to the convention for an empty product.

The factorial operation is encountered in many areas of mathematics, notably in combinatorics, algebra, and mathematical analysis. Its most basic occurrence is the fact that there are n! ways to arrange n distinct objects into a sequence (i.e., permutations of the set of objects). This fact was known at least as early as the 12th century, to Indian scholars. Fabian Stedman in 1677 described factorials as applied to change ringing.

Information source: wikipedia.org


Program:->

Program Output
Output

f = 1
x = input("Enter a number: ")
for i in range(1,x+1):
    f = f * i
print "Factorial: %d" % f
Read More >>


  In mathematics, the factorial of a non-negative integer n, denoted by n!, is the product of all positive integers less than or equal to n. For example,

5! = 5  *  4  *  3  *  2  * 1 = 120.
The value of 0! is 1, according to the convention for an empty product.

The factorial operation is encountered in many areas of mathematics, notably in combinatorics, algebra, and mathematical analysis. Its most basic occurrence is the fact that there are n! ways to arrange n distinct objects into a sequence (i.e., permutations of the set of objects). This fact was known at least as early as the 12th century, to Indian scholars. Fabian Stedman in 1677 described factorials as applied to change ringing.

Information source: wikipedia.org


Program:->

Program Output
Output

import java.util.Scanner;
public class SeFact {
    public static void main(String[] args) {
        int x, f = 1;
        System.out.print("Enter a number: ");
        Scanner sc = new Scanner(System.in);
        x = sc.nextInt();
        for (int i = 1; i <= x; ++i) {
            f = f * i;
        }
        System.out.println("Factorial: " + f);
    }
}


Note: The program must be saved with name "SeFact.java" 
Read More >>

Saturday, 19 March 2016


     In computer science, a search allows the efficient retrieval of specific items from a set of items, such as a specific record from a database.

The simplest, most general, and least efficient search structure is merely an unordered sequential list of all the items. Locating the desired item in such a list, by the linear search method, inevitably requires a number of operations proportional to the number n of items, in the worst case as well as in the average case. Useful search data structures allow faster retrieval; however, they are limited to queries of some specific kind. Moreover, since the cost of building such structures is at least proportional to n, they only pay off if several queries are to be performed on the same database (or on a database that changes little between queries).
Information source: wikipedia.org


Program:->

Program Output
Output

#include <stdio.h>
#include <conio.h>
int main()
{
int loc, n, data, x, a[100];
printf("Enter no. of values: ");
scanf("%d", &n);
printf("Enter %d values: ", n);
for(x=0; x<n; x++) {
scanf("%d", &a[x]);
}
printf("Entered array is: \n");
for(x=0; x<n; x++) {
printf("%d  ", a[x]);
}
printf("\nEnter data to search: ");
scanf("%d", &data);
for(x=0; x<n; x++) {
if(data==a[x]) {
printf("Location is: %d\n", x);
loc=x;
break;
}
loc=x;
}
if(data!=a[loc]) {
printf("Element not found\n");
}
return(0);
}
Read More >>


         In mathematics, the factorial of a non-negative integer n, denoted by n!, is the product of all positive integers less than or equal to n. For example,

5! = 5  *  4  *  3  *  2  * 1 = 120.
The value of 0! is 1, according to the convention for an empty product.

The factorial operation is encountered in many areas of mathematics, notably in combinatorics, algebra, and mathematical analysis. Its most basic occurrence is the fact that there are n! ways to arrange n distinct objects into a sequence (i.e., permutations of the set of objects). This fact was known at least as early as the 12th century, to Indian scholars. Fabian Stedman in 1677 described factorials as applied to change ringing.


Information source: wikipedia.org


Program:->

Program Output
Output

#include <stdio.h>
#include <conio.h>
int main() {
int x,f=1,i;
printf("Enter a number: ");
scanf("%d", &x);
for (i = 1; i <= x; ++i)
{
f=f*i;
}
printf("Factorial: %d\n",f);
return(0);
}
Read More >>


         In mathematics, the Fibonacci numbers or Fibonacci sequence are the numbers in the following integer sequence:

01, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144.....

The Fibonacci spiral: an approximation of the golden spiral created by drawing circular arcs connecting the opposite corners of squares in the Fibonacci tiling; this one uses squares of sizes 1, 1, 2, 3, 5, 8, 13, 21, and 34.
By definition, the first two numbers in the Fibonacci sequence are either 1 and 1, or 0 and 1, depending on the chosen starting point of the sequence, and each subsequent number is the sum of the previous two. 
Information source: wikipedia.org


Program:->

Program Output
Output

#include <stdio.h>
#include <conio.h>
int fibo(int);
int main() {
int n;
printf("Enter the total elements in the series: ");
scanf("%d", &n);
printf("The Fibonacci series is: \n");
fibo(n);
return(0);
}
int fibo(int x) {
int f=-1,s=1,n, i;
for (i = 0; i < x; i++) {
n=f+s;
f=s;
s=n;
printf("%d\n", n);
}
return(0);
}
Read More >>


Copyright © 2016 - ProgrmIt - All Rights Reserved
(Articles Cannot Be Reproduced Without Author Permission.)
Design By : Mr. Proger | Powered By: Blogger