Friday, December 16, 2011

PL/SQL Sample Examples

Hello Friends, here discuss some sample examples related to PL/SQL programming language. These all are basic example to understand PL/SQL syntax.
I used oracle 10g during program development. There are program to understand declare statement, loop concept, procedure, function, exception handling, cursor etc.


PL/SQL Sample Examples List

1. PL/SQL Example to find average of three numbers

2. PLSQL Example Find Even Odd Number

3. PL/SQL program to generate Fibonacci series

4. Check Number is Armstrong in PL/SQL Programming

5. PL/SQL Program to reverse a string

6. Basic LOOP Program in PL/SQL

7. PLSQL FOR Loop Example

8. Reverse a Number in PL/SQL Programming

9. PL/SQL Procedure Sample Example

10. Function Example in PL/SQL Oracle

11. Exception Handling Program in PL/SQL Oracle

Hope, these sample programs help you to understand PL/SQL programming language.

Thursday, December 15, 2011

C Program to String Reverse

It is a basic C program to reverse a string.
In this c programming example user input a string and get reverse of accepted string.

Aim - C program to reverse accepted string [Using strrev function]


Program Code
//String Reverse using strrev function
#include"stdio.h"
#include"conio.h"
#include"string.h"
void main()
{
   char str[20];
   clrscr();
   printf("********* String Reverse Using strrev Function *******\n");
   printf("Enter a string:  ");
   gets(str);
   strrev(str);
   printf("\n Reverse string is:  %s",str);
   getch();
}
Output




Aim - C program to reverse accepted string [without using strrev function]


Program Code
//String Reverse without using strrev function
#include"stdio.h"
#include"conio.h"
#include"string.h"
void main()
{
 char str1[20],str2[20];
 int i,j=0;
 clrscr();
 printf("***********String Reverse*********\n");
 printf("Enter String:");
 gets(str1);
 for(i=strlen(str1)-1;i>=0;i--,j++)
 {
  str2[j]=str1[i];
 }
 str2[j]=NULL;
 printf("\nReverse String is:");
 puts(str2);
 getch();
}

Output

Why C is Called Middle Level Language?

Why C is Called Middle Level Language?

C language supports high level language which is user friendly and low level language which is machine friendly.
C combines features of a high level language with the functions of an assembly level language. It reduces the gap between low level language and high level language.
So C language called as middle level language.


C contains many features of high level language like modular programming, user friendly, loop, arrays etc. C language is also related to machine level language(low). It provides features like access to memory using pointers and assembly aspects.
C is one of the language who able to directly interact to system.
C language is used to develop both user applications and operating systems.

Thus, C is called as Middle Level Language.



Friday, December 2, 2011

C program for Bubble Sort

Today I am going to share how to perform bubble sort in C programming language. What is Bubble Sort? Bubble sort is a very simple sorting algorithm which compares consecutive numbers and swap them if both are not in right order. This gives the biggest element at the end in each inner loop cycle. Here is an animated example for bubble sort:
#include
#include

  void bubbleSort(int arr[],int length)
  {
        int i,j,temp;
         for(i=length;i>0;i--)
         {
            for(j=0;j<=i;j++)
   { 
                if(arr[j]>arr[j+1])
                { 
//swap if previous value is bigger then next value
                    temp=arr[j];
     arr[j]=arr[j+1];
                    arr[j+1]=temp;
                }
   }// End of Inner For loop
        }// End of Outer For loop.
  }// End of BubbleSort Function
  


 void main()
 {

  
  int data[] = {4,3,5,2,9,2,1,8,7,0}
  int i;

  clrscr();

  printf("\nData before sorting: ");
  
  for( i=0; i<10; i++)
  { 
   printf("%d , ",data[i]);
  }
       
  bubbleSort(data,10);

  printf("\nData after sorting: ");
  
  for( i=0; i<10; i++)
  {
   printf("%d , ",data[i]);
  }
  
  } //End of this example.