Posts

Showing posts from 2012

Tell Me Something About Yourself - Interview Answers.

Try to introduce some of your most important employment-oriented skills as well as your education and accomplishments to the interviewer. Answer to this question is very important because it positions you for the rest of the interview. That's why this statement is often called the " Positioning Statement".

One should take the opportunity to show his/her communication skills by speaking clearly and concisely in an organized manner. Since there is no right or wrong answer for this question hence it is important to appear friendly.



YOUR ANSWERS CAN BE:

1) I am a person with strong interpersonal skills and have the ability to get along well with people. I enjoy challenges and looking for creative solutions to problems.

2) Besides the details given in my resume, I believe in character values, vision and action. I am quick in learning from mistakes. I am confident that the various tests that you have conducted will corroborate my competencies aptitude and right attitude for th…

Sample C Program To Delete All Vowels From A Sentence / String.

void main()
  {
     char sent[ ] = "She sells seashells on the seashore";
     int i;

     for(i = 0; sent[i] != 0; i++)
       {
            if(sent[i] == 97 || sent[i] == 101 || sent[i] == 105 || sent[i] == 111 || sent[i] == 117)
               {
                   for(;sent[i + 1] != 0; i++)
                       sent[i]=sent[i + 1];

                   sent[i] = '\0';
                   i =- 1;
               }

       }
     printf("\n %s", sent);
  }


ALSO CHECK THESE C PROGRAMS:

86. C Program To Accept A String & Display It.
87. C Program To Find The Length Of A String.
88. C Program To Concatenate Two Strings.
89. C Program To Compare Two Strings.
90. C Program To Swap Two Strings.


91. C Program To Swap Two Strings Using strcpy() Function.
92. C Program To Sort A Given Number Of Strings Using strcmp() Function.
93. C Program To Check Whether A String Is Palindrome Or Not.
94. C Program To Print The Reverse Of A String.
95. C Program To Join Two Stri…

Sample C Program To Count The Number Of Occurrences Of Any Two Vowels In Succession In A Line Of Text.

Image
This program lets the user know the number of occurences of any two vowels in succession in the text passed in the program. For example, in the sentence “Please read the document carefully and then sign the gratuity form.” Such occurrences are ea, ea, ui.


void main()
  {
     char sent[ ] = "Please read the document carefully and then sign the gratuity form.";
     int i, c;

     for(i = 0, c = 0; sent[ i ] != '\0'; i++)
        {
            if( (sent[i] == 97 || sent[i] == 101 || sent[i] == 105 || sent[i] == 117 )&&(sent[i + 1] == 97 || sent[i + 1] == 101 || sent[i + 1] == 105 || sent[i + 1] == 111 || sent[i + 1] == 117))
            c++;
        }
     printf("\nThere are %d occurences of two vowels in succession",c);
  }


ALSO CHECK THESE C PROGRAMS:

- C Program to count the number of words, characters, alphabets, vowels, consonants and digit in a line of text. 

- C Program to accept two string and compare the strings are equal or not.

- C Pr…

Sample C Program To Compare Two Dates Using Structures.

Image
In this program user enters two dates for comparison. In order to store date we will use structure say date that contains three members namely date, month and year. If the dates are equal then display message as “Dates are Same." otherwise “Both the dates are different”. 

void main()
{
    int i, f = 0;

    struct date
      {
         int date;
         int month;
         int year;
      };

    struct date d[2];

    for(i = 0; i < 2; i++)
      {
         printf("\n Enter day for the %d date \n", i + 1);
         scanf("%d",&d[i].date);
         printf("\n Enter the month for the %d) date \n", i + 1);
         scanf("%d",&d[i].month);
         printf("\n Enter the year for the %d) date \n", i + 1);
         scanf("%d",&d[i].year);
      }

    if(d[0].date == d[1].date)
      {
         if(d[0].month == d[1].month)
            {
                if(d[0].year == d[1].year)
                  {

Sample C Program to accept a string and print the reverse of the given string.

Image
40) Sample C Program to accept a string and print the reverse of the given string.

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

main( )
{
int i, j;
char name[80];
clrscr( );
printf("Enter a string");
gets(name);

for(i = 0; i < 80 && ((name [i] = getchar()) != '\n'); i++);
     if(name[i]= ='\n')
         name[i]='\0';

for(j=i;j>=0;j--)
      putchar(name[j]);

printf("Is the reverse of given string");
getch( );
}


41) Sample C Program to accept a string and check whether the given string is palindrome or not.

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

main( )
{
int i, lim, c, check = 1;
char word[80];
clrscr( );
printf("Enter a string");

for(i = 0; i < 80 && ((word [i] = getchar()) != '\n'); i++);

lim = i - 1;
c = lim / 2;

for(i = 0; i <= 0; i++, lim--)
     if(word[i] != word[lim])
       {
          check = 0;
          break;
       }

if(check == 1)
     printf("The given str…

Sample C Program to accept two string and compare the strings are equal or not.

Image
46) Sample C Program to count the number of words, characters, alphabets, vowels, consonants and digit in a line of text.

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

main( )
{
int noa = 0, nob = 0, noc = 0, nov =0 , now = 0, noch = 0, l, I;
char ch, s[100];
clrscr( );
printf("Enter 2 lines of text:");

gets(s);
l = strlen(s);

for(i = 0; i < 1; i++)
   {
      switch(s[i])
        {
           case 'a':
           case 'e':
           case 'i':
           case 'o':
           case 'u':
           case 'A':
           case 'E':
           case 'I':
           case 'O':
           case 'U':
                         nov++;
                         break;
        }

      if(isalpha(s[i]))
           noa++;

      if(isdigit(s[i]))
           nod++;

      if(noa[i] == ' ') && (noa[i + 1] != ' ')
           now++;

   }

noch = l - nob;
noc = noa - nov;

printf("Total …

Sample C Program to print upper triangle.

Image
43) Sample C Program to print upper triangle.

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

main( )
{
int a[4][4], i, j, c;
clrscr( );

printf("Enter the no. for which you want upper triangle:");
scanf("%d", &c);

for(i = 0; i < 4; i++)
   for(j = 0; j < 4; j++)
       if(i < j)
           a[i][j] = c;
       else
           a[i][j] = 0;

for(i = 0; i < 4; i++)
   for(j = 0; j < 4; j++)
     {
        printf("%d:", a[i][j]);
        printf('\n');
     }

getch( );

}


44) Sample C Program to accept two 3 dimensional array and store addition of those into the third 3-D array .

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

main( )
{
int a[3][3], b[3][3], c[3][3], i, j;
clrscr( );

for(i = 0; i < 3; i++)
   for(j = 0; j < 3; j++)
     {
        printf("Enter the two values for a[%d][%d] & b[%d][%d]", i, j, i, j);
        scanf("%d %d", &a[i][j], &b[i][j]);
     }

for(i = 0; i < 3; i++)
 …

Sample C Program For Armstrong Numbers

Image
7) Sample C Program to print sum of individual digits of given number.

# include <stdio.h>
# include <conio.h>
main( )
{
int a, b, c, d;
clrscr( );
printf ( "Enter any two digit number :");

scanf ("%d", &a);

b = a / 10;
c = a % 10;
d = b + c;
printf ("Sum of individual digits of given numbers is %d", d);

getch( );

}


8) Sample C Program Program to accept a three digit number and print the sum of individual digits.

# include <stdio.h>
# include <conio.h>
main( )
{
int a, b, c, n, sum;
clrscr( );

printf ("Enter a Three Digit Number:");
scanf ("%d",&n);

a = n / 100;
b = ( ( n % 100 ) / 10 );
c = n % 10;
sum = a + b + c;

printf ("Sum of Individual Digits of Given Numbers is %d", Sum);
getch( );
}


9. Sample C Program to accept a number and check the given number is Armstrong or not.

# include <stdio.h>
# include <conio.h>
main( )
{
int n, a, b, c, d;
clrscr( );

printf ("Enter a Three D…

Sample C Program To Print A Message.

Image
1) Sample C Program To Print A Message.

# include <stdio.h>
# include <conio.h>
main()
{
clrscr();
printf("HELLO WELCOME TO WWW.INTERVIEW-MADE-EASY.COM");
printf("Answers To All Important Interview Questions");
getch();
}


2) Sample C Program To Read Two Numbers And Print The Sum Of Given Two Numbers.

# include <stdio.h>
# include <conio.h>
main()
{
int a,b, sum;
clrscr ();

printf ("ENTER VALUE FOR A;");
scanf ("%d",&a);

printf("ENTER VALUE FOR B;");
scanf("%d",&b);

sum = a + b;
printf("Sum Of Given Two Numbers are %d", sum);
getch();
}


3) Sample C Program To Accept Student Roll No, Marks in 3 Subjects and Calculate Total, Average and Print it.

# include <stdio.h>
# include <conio.h>
main()
{
int r, b, c, d, tot, avg;
clrscr();
printf ("ENTER STUDENT RNO;");
scanf ("%d",&r);

printf("ENTER FIRST SUBJECT MARKS ;");
scanf("%d",&…

Sample C Program To Check Leap Year Using Logical Operator & Functions

C Program To Read Three Numbers And Print The Biggest Of Given Three Numbers.

# include <stdio.h>
# include <conio.h>
main( )
{
    int a, b, c, big = 0;
    clrscr( );
    printf("Enter Value For A:");
    scanf("%d",& a);

    printf("Enter Value For B:");
    scanf("%d",& b);

    print("Enter Value For C:");
    scanf("%d",& c);

    if (a > big)
        big = a ;
    if(b > big)
        big = b;
    if (c > big)
        big = c;

    printf (“Biggest Of Above Given Three Number Is %d”, big)
    getch( );
}


C Program To Find Whether The Given Number Is Even Or Odd Using Modulus Operator.

# include <stdio.h>
# include <conio.h>
main()
{
    int n, r;
    clrscr();

    printf("Enter a No. ;");
    scanf("%d", & n);

    r = n % 2;

    if(r == 0)
        printf("The above given number is an even number.");
    else
        printf("The above given …

Sample C Program to accept a string in upper case and print it in lower case.

Image
28) Sample C Program to accept a string and print it by using the while loop.

# include <stdio.h>
# include <conio.h>
main( )
{
char ch;
clrscr();
printf("Enter a string:");
while(( ch = getchar() ) != '\n')
   putchar(ch);
getch();
}


29) Sample C Program to accept a string in upper case and print it in lower case.

# include <stdio.h>
# include <conio.h>
main( )
{
char ch,c;
clrscr();
printf("Enter a string in upper case:");

while(( ch = getchar( ) ) != '\n')
  {
     c = ch + 32;
     putchar(c);
  }

printf(" :String In Lower Case");
getch( );
}


30) Sample C Program to accept a string in any case and print it by another case.

# include <stdio.h>
# include <conio.h>
main( )
{
char ch;
clrscr( );
printf("Enter a string:");
 while(( ch = getchar( )) != '\n')
{
if(ch >= 'A' && ch <= 'Z')
putchar(ch + 32);
else
if(ch >= 'a' && ch <= 'z&#…

Sample C Program to print numerical pyramid.

Image
16) Sample C Program to print numeric pyramid.

# include <stdio.h>
# include <conio.h>
main()
{
int i, j;
clrscr( );

for(i = 1; i <= 5; i++)
 {
   for(j = 1; j <= i; j++)
     printf("%d", j);
  printf("\n");
 }

getch();
}


17) Sample C Program to print numerical pyramid.

# include <stdio.h>
# include <conio.h>
main()

{
int i, j, l, k = 40;
clrscr( );

for(i = 1; i <= 9; i += 2)
 {
   for(l = 1; l <= k; l++)
      printf(" " );

   for(j = 1; j <= i ; j++);
      printf("%d", j);

   printf("\n");
   k = k - 2;
 }

getch( );
}


18) Sample C Program to print numerical diamond.

# include <stdio.h>
# include <conio.h>
main( )
{
int i, j, l, n, s, k = 40;
clrscr( );

for(i = 1; i <= 9; i += 2)
 {
    for(l = 1; l <= k; l++)
      printf(" ");

    for(j = 1; j <= i; j++)
       printf("\n");

    k = k - 2;
 }

k = k + 4;

for(n = 7; n >= 1; n -= 2)
 {
    for(i = 1; …

C Program To Print Pyramid Of Numbers.

19) Sample C Program to print character pyramid.

# include <stdio.h>
# include <conio.h>
main( )
{
char i, j;
clrscr();
for(i = 65; i <= 70; i++)
 {
   for(j = 65; j <= i; j++)
      printf("%c", j);
   printf("\n");
 }
getch( );
}


20) Sample C Program to print character diamond.

# include <stdio.h>
# include <conio.h>
main( )
{
char i, j, n, r;
int s, sp = 40;
clrscr( );
for(i = 65; i <= 75; i += 2)
 {
   for(s = 1; s <= sp; s++)
      printf(" ");

   for(j = 65; j < i; j++)
      printf("%c", j);

   printf("\n");
   sp = sp - 2;
 }

sp = sp + 4;

for(n = 73; n >= 65; n -= 2)
 {
   for(s = 1; s <= sp; s++)
      printf(" ");

   for(r = 65; r <= n; r++)
      printf("%c",r);

   sp = sp + 2;
 }
getch( );
}


21) Sample C Program to find biggest of two no by using ternary operator.

# include <stdio.h>
# include <conio.h>
main( )
{
int a, b, big;
clrscr( );

printf(…

C Program To Find Largest/Smallest Of Four Nos. Using Ternary Operator.

22) Sample C Program to find largest of four nos. by using Ternary Operator.

# include <stdio.h>
# include <conio.h>
main( )
{
int a, b, c, d, big;
clrscr( );
printf("Enter the value of a:");
scanf("%d",&a);
printf("Enter the value of b:");
scanf("%d",&b);
printf("Enter the value of c:");
scanf("%d",&c);
printf("Enter the value of d:”);
scanf("%d",&d);
big = (a > b)?(a > c)?(a > d)?a:d:(c > d)?c:d:(b > c)?(b > d)?b:d:(c > d)?c:d;
printf("Biggest of the given 4 numbers is %d", big);
getch();
}


23) Sample C Program to find smallest of four nos. by using Ternary Operator.

# include <stdio.h>
# include <conio.h>
main( )
{
int a, b, c, d, small;
clrscr( );
printf("Enter the value of a:");
scanf("%d",&a);
printf("Enter the value of b:");
scanf("%d",&b);
printf("Enter the value of c:");
scanf…

C Program To Print Multiplication Table Using For Loop.

13) Sample C Program to accept a number and print mathematical table of the given no.

# include <stdio.h>
# include <conio.h>
main( )
{
int i, t;
clrscr( );
printf("Which table you want:");
scanf("%d",&t);

for (i = 1; i <= 10; i++)
   printf("\n%d * %d = %d", t, i, i * t);

getch( );
}


14) Sample C Program to print 1 to 10 mathematical tables.

# include <stdio.h>
# include <conio.h>
main( )
{
int i, j;
clrscr( );

for (i = 1; i <= 10; i++)
  for (j = 1; j <= 10; j++)
    printf("\n%d * %d = %d", i, j, i * j);

getch( );
}


15) Sample C Program to print Fibonacci series.

# include <stdio.h>
# include <conio.h>
main( )
{
int a = 0, b = 1, c = 0, i;
clrscr( );
printf("%d",a);
printf("\n%d",b);

for (i = 1; i <= 10; i++)
 {
   c = a + b;
   printf("\n%d", c);
   a = b;
   b = c;
 }

getch( );
}


C Program To Print ODD Numbers From 1 To 100.

10) Sample C Program to print ODD numbers from 1 to 100.

# include <stdio.h>
# include <conio.h>
main( )
{
int i;
clrscr( );

for (i = 1; i <= 100; i += 2)
printf("%d\n",i);

getch( );
}


11) Sample C Program to print natural numbers from 1 to 100 in reverse order.

# include <stdio.h>
# include <conio.h>
main( )
{
int i;
clrscr( );

for (i = 100; i >= 1; i --)
printf(“%d\n”,i);

getch( );
}


12) Sample C Program to print sum of the natural numbers from 1 to 100.

# include <stdio.h>
# include <conio.h>
main( )
{
int n, sum = 0, i;
clrscr( );

for (i = 1; i <= 100; i ++)
sum = sum + i;

printf("Sum of natural numbers from 1 to 100 is %d\n",sum);
getch( );
}


C Program to Check Given No. Is Armstrong Number Or Not.

37) Sample C Program to accept a number and check whether the given number is an Armstrong number or not.

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

main( )
{
int n, arm;
clrscr();
printf("Enter any 3 digit number:")
scanf("%d",&n);

arm = armstrong(n);

if(arm == n)
   printf("%d is an Armstrong number.",n);
else
   printf("%d is not an Armstrong number.",n);
getch( );
}


int armstrong (int n)
{
int a, b, c, d;
a = n / 100;
b = ( (n / 10) % 10);
c = n % 10;
d = a*a*a + b*b*b + c*c*c;
return d;
}


38) Sample C Program to accept a number and print the sum of given and reverse number.

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

main( )
{
int a, b, n;
clrscr( );
printf("Enter a number:")
scanf("%d",&n);

a = rev(n);

printf("Reverse of a given number is: %d", a);

b = add(n, a);

printf("\n Sum of a given and reverse number is: %d", b);
getch( );
}


int rev(int n)
{
int r, rev = 0, s;
while(n &…

C Program To Convert Uppercase To Lowercase.

25) Sample C Program to accept a character in Uppercase & print in Lowercase.

# include <stdio.h>
# include <conio.h>
main( )
{
char ch, c1;
clrscr( );

printf("Enter a character in Uppercase:");
ch = getchar();

c1 = ch + 32;

printf("The given character in Lowercase is:");
putchar(c1);

getch();
}


26) Sample C Program to accept a character in any case and print it in another case.

# include <stdio.h>
# include <conio.h>
main( )
{
char ch, c1;
clrscr( );

printf("Enter a character in any case(Uppercase/Lowercase):");
ch = getchar();

if(ch >= 65 && ch <= 90)
   c1 = ch + 32;
elseif(ch >= 97 && ch <= 122)
   c1 = ch - 32;
endif;

printf("The given char in other case is:");
putchar(c1);

getch();
}



27) Sample C Program to print natural number from 1 to 10 by using while loop.

# include <stdio.h>
# include <conio.h>
main( )
{
int a = 0;
clrscr();

while( a < 10)
  {
     a = a + 1;
     p…

C Program To Find Prime Number Between 1 And 100.

34) Sample C Program to print prime numbers between 1 to 100.

# include <stdio.h>
# include <conio.h>
main( )
{
int n, i, check;
clrscr();
for(i = 1; i <= 100; i++)
{
check = 1;
for(n = 2; n <= i / 2; n++)
if(i % n == 0)
{
check = 0;
break;
}
if(check == 1)
printf("\n %d is a prime", i);
else
printf("\n %d is not a prime", i);
}
getch( );
}


35) Sample C Program to accept two numbers and print sum of two numbers by using functions.

# include <stdio.h>
# include <conio.h>
main( )
{
int a, b, c;
clrscr();

printf("Enter the value for a:")
scanf("%d",&a);

printf("Enter the value for b:")
scanf("%d",&b);

c = add(a, b);
printf("Sum of two numbers is %d",c);
getch( );
}

int add(int x, int y)
{
int z;
z = x + y;
return z;
}


36) Sample C Program to accept a number and find factorial of given number.

# include <stdio.h>
# include <conio.h>
main( )
{
int n, f;
clrscr( );

printf(&q…

String Programs In C Programming Asked In Interviews.

31) Sample C Program to accept a string and print each word in new line.

# include <stdio.h>
# include <conio.h>
main( )
{
char ch;
clrscr( );
printf("Enter a string :");
while( ( ch = getchar( ) ) != '\n')
{
putchar(ch);
if(ch == ' ')
printf("\n");
}
getch( );
}


32) Sample C Program to accept a string and count no of capital letters, no. of small letters and no. of special characters.

# include <stdio.h>
# include <conio.h>
main( )
{
char ch;
int c = 0,s = 0,s1 = 0;
clrscr( );
printf("Enter a string :");

while( ( ch = getchar( ) ) != '\n')
  {
     if(ch >= 'A' && ch >= 'Z')
        c = c + 1;
     else if(ch >= 'a' && ch >= 'z')
        s = s + 1;
     else
        s1 = s1 + 1;
  }

printf("No. of capital letters are %d", c);
printf("No. of small letters are %d", s);
printf("No. of special characters are %d", s1);
getch…

Sample C Program To Implement Minimum Spanning Tree Using Functions, Pointers & Structures.

ALGORITHM:

STEP 1: Start the program.
STEP 2: Assign MAX a constant value of 20.
STEP 3: Declare a structure edge with structure variable *front.
STEP 4: Define the functions and variables required in the program globally.
STEP 5: Call the function create_graph() inside the main function.

STEP 6: Call the function make_tree().
STEP 7: Set a for loop using i.
for(i = 1; i <= count; i++)
STEP 8: Print the values of tree[i].u and tree[i].v
STEP 9: Stop the program.


FUNCTION OF CREATE_GRAPH ( )

STEP 1: Declare the local variables.
STEP 2: Read the number of nodes n.
STEP 3: Calculate the value of max_edge as
max_edge = n * (n - 1) / 2.
STEP 4: Set a for loop using i.
for(i = 0; i <= max_edge; i++)
STEP 5: Read the values of origin and destiny.

STEP 6: Check whether origin and destiny are equal to 0.
STEP 7: If so exit the loop using break statement
STEP 8: Read the weight of the current edge wt.
STEP 9: Check the following condition.
if(origin > n || destin > n || origin <= 0 || destin <=…

Sample C Program To Implement 8 Queens Problem Using Arrays, Pointers & Functions.

ALGORITHM:

STEP 1: Define the functions that are to be used.
STEP 2: Assign a constant value of 8 to QUEENNO.
STEP 3: Call the function placequeen(0, x).
STEP 4: Print the message “End”.
STEP 5: Stop the program.


FUNCTION VOID PLACEQUEEN(int k, int *x)

STEP 1: Declare local variables
STEP 2: Set a for loop for i.
for(i = 0; i < 8; i++)
STEP 3: Check for result of function canbeplaced(k, I, x).
STEP 4: If it is 1 then assign the value of i to x[k].
x[k] = i;
STEP 5: Check if k is equal to 7 if show call the function showboard(x).

STEP 6: Read the value of ch from the user.
STEP 7: If the value is equal to n or N then exit.
STEP 8: Check whether k is less than 7 if so then call the function placequeen(k + 1, x).


FUNCTION INT CANBEPLACED(int k, int i, int *x)

STEP 1: Declare the local variables.
STEP 2: Set a for loop for j.
for(j = 0; j < k; j++)
STEP 3: Check for the following condition
if( (abs(j - k) == abs(x[j] - i) || (x[j] == i) ) )
STEP 4: If its true return 0 else return 1.

FUNCTION VOID SHOW…

Sample C Program To Implement Quick Sort Using Pointers, Functions & Arrays.

ALGORITHM:

STEP 1: Start the program.
STEP 2: Assign the pointer array *a[100] as global, Read the value of n.
STEP 3: Set a for loop to read the elements of array.
for(i = 0; i < n; i++)
STEP 4: Call the function sort(0, n - 1).
STEP 5: Print the sorted array a.
STEP 6: Stop the program


FUNCTION SORT (int first, int last)

STEP 1: Declare the local variable.
STEP 2: Check if first is less than last.
first < last


STEP 3: If so then assign the following
pivot = a[first]
i = first
j = last


STEP 4: Assign a while loop till the condition.
I < j

STEP 5: Assign a while loop to increment i till
a[i] < pivot and i < last

STEP 6: Assign a while loop to decrement j till
a[j] > pivot and j > first


STEP 7: Check whether i is than j if so then swap the values of a[i] and a[j]
temp = a[i]
a[j] = a[j]
a[j] = temp


STEP 8: Then swap the values of a[j] and a[first].
temp = a[j]
a[j] = a[first]
a[first] =temp

STEP 9: Call another functions sort(first, j - 1) and sort(j + 1, last)


SAMPLE PROGRAM:


#in…

Sample C Program To Implement Binary Search Without Using Recursive Function.

ALGORITHM:

STEP 1: Start the program.
STEP 2: Read the value of n.
STEP 3: Set a for loop to read the elements of array.
for(i = 0; i < n; i++)
STEP 4: Set a for loop.
for(i = 0; i < n; i++)
STEP 5: Nest another for loop.
for(j = i + 1; j < n; j++)

STEP 6: Check the condition a[i] > a[j]
STEP 7: If so swap the two values using temporary variable t as
t = a[i]
a[i] = a[j]
a[j] = t
STEP 8: Else go back to step 6.
STEP 9: Set a for loop to print the value of array a.
for(i = 0; i < n; i++)
STEP 10: Read the search key as k.

STEP 11: Assign low = 0 and high = n – 1.
STEP 12: Call the function binsearch(a, k, low, high)
STEP 13: Check if ans is not equal to 1, if so print the position b + i. else print that element is not found.
STEP 14: Stop the program.


FUNCTION BINARY SEARCH (int *a[ ], int x, int low, int high)

STEP 1: Check if low > high if so return -1.
STEP 2: Else assign mean value of low and high to mid.
mid = ( high + low ) / 2.
STEP 3: Assign the value of a[mid] to p
p = a[mid]
S…

Sample C Program To Implement Binary Search Using Recursive Function.

ALGORITHM:

STEP 1: Start the program.
STEP 2: Read the value of n.
STEP 3: Set a for loop to read the elements of array.
for(i = 0; i < n; i++)
STEP 4: Set a for loop.
for(i = 0; i < n; i++)
STEP 5: Nest another for loop.
for(j = i + 1; j < n; j++)

STEP 6: Check the condition a[i] > a[j].
STEP 7: If so swap the two values using temporary variable t as
t = a[i]
a[i] = a[j]
a[j] = t
STEP 8: Else go back to step 6.
STEP 9: Set a for loop to print the value of array a.
for(i = 0; i < n; i++)
STEP 10: Read the search key as k.

STEP 11: Assign low = 0 and high = n – 1.
STEP 12: Call the function binsearch(a, k, low, high)
STEP 13: Check if ans is not equal to 1, if so print the position b + i. Else print that element is not found.
STEP 14: Stop the program.


FUNCTION BINARY SEARCH (int *x[ ], int x, int low, int high)

STEP 1: Set a while loop till low is greater than high.
STEP 2: Assign mean value of low and high to mid.
mid = (high + low) / 2
STEP 3: Assign the value of x[mid] to p.
p = x[mid…