Software Programs

Program to arrange the string in alphabetical order

Here is the program to arrange the string in alphabetical order. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 #include "stdio.h" #include "conio.h" #include "string.h" void main() { char str[10],temp; int i,j; clrscr(); printf("\nEnter the string : "); scanf("%s",str); for(i=0;i<strlen(str);i++) for(j=0;j<strlen(str);j++) if(str[i]<str[j]) […]


Binary Search

A binarysearch program locates the position of an item in a sorted array. Logic: The Binary search starts by testing the element at the middle of the array. Let us consider an array ‘a’ with all elements arranged in ascending order. Let low and high are the lower and upper indices of the array ‘a’, respectively. We want to search an item […]


Java program to print Fibonacci sequence Recursive & Non Recursive

The Fibonacci sequence is defined by the following rule. The first 2 values in the sequence are 1, 1. Every subsequent value is the sum of the 2 values preceding it. Write a Java program that uses both recursive and non-recursive functions to print the nth value of the Fibonacci sequence. 1 2 3 4 […]


Java program to display triangle 1 24 369 481216

/* Display Triangle as follow 1 2 4 3 6 9 4 8 12 16 … N (indicates no. of Rows) */ class Output3{ public static void main(String args[]){ int n = Integer.parseInt(args[0]); for(int i=1;i


Java program to display triangle 0 10 101 0101

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 /* Display Triangle as follow 0 1 0 1 0 1 0 1 0 1 */ class Output2{ public static void main(String args[]){ for(int i=1;i<=4;i++){ for(int j=1;j<=i;j++){ System.out.print(((i+j)%2)+" "); } System.out.print("\n"); } } }


Java program to display triangle 1 23 456 78910

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 /* Display Triangle as follow : BREAK DEMO. 1 2 3 4 5 6 7 8 9 10 … N */ class Output1{ public static void main(String args[]){ int c=0; int n = […]