Posts

Showing posts from 2011

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 Find Out The No. Of Times A Character Is Present In The String.

This is a Sample C Program To Accept A String & Find Out Whether This Character Is Present In The String.

If Present Then Display How Many Times This Character Occurs.


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

void s(char *p,char hc);

void main()
{

char str[10];
char ch;
clrscr();

printf(" \n \n Enter the string: \t ");
gets(str);

printf(" \n \n Enter the character: \t ");
scanf("%c",&ch);
s(str,ch);

}

void s(char *p,char hc)
{

int a = 0;
int i,l;
l = strlen(p);

for(i = 0; i < l; i++)
  {
     if ( p[i] == hc)
       {
         a++;
       }
     else
         continue;
  }

printf(" \n \n The Entered Character occurs %d times. ", a);
getch();

}


OUTPUT: 

Enter the string: Googleplus
Enter the character: l
The Entered Character occurs 2 times.


ALSO READ:

Sample C Program To Accept A String & Find Out Whether This Character Is Present In The String.

Sample C Program To Accept A String & Display I…

Sample C Program To Accept A String & Find Out Whether This Character Is Present In The String.

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

void s(char *p,char hc);

void main()
{

char str[10];
char ch;

clrscr();
printf(" \n \n Enter the string: \t ");

gets(str);
printf(" \n \n Enter the character: \t ");

scanf("%c",&ch);
s(str, ch);

}

void s(char *p,char hc)
{

int a;
int i,l;

l = strlen(p);

for(i = 0; i < l; i++)
{
if(p[i] == hc)
  {
     a++;
  }
else
     continue;
}

if(a >= 1)
  {
     printf(" \n \n Yes, the entered character is present in the string. ");
  }
else
  {
     printf(" \n \n No, the entered character is not present in the string. ");
  }
getch();
}


OUTPUT:

Enter the string: Malayalam
Enter the character: z
No, the entered character is not present in the string.


ALSO READ:

Sample C Program To Accept A String & Display It's Substring.

Sample C Program To Accept A String & Display It's Alternate Characters In Reverse.

Sample C Program To Accept Two Strings & Dis…

Sample C Program To Accept A String & Display Number Of Each Vowels.

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

char vowels(char *p);

void main()
{

char str[10];
clrscr();

printf(" \n \n Enter the string: \t ");
gets(str);

vowels(str);
getch();

}

char vowels(char *p)
{

int i, l, v1 = 0, v2 = 0, v3 = 0, v4 = 0, v5 = 0, v6 = 0, v7 = 0, v8 = 0, v9 = 0, v10 = 0;
l = strlen(p);

printf(" \n \n The number of vowels in the string is: \t ");

for( i = 0; i < l; i++ )
{
if ( p[i] == 'a' )
  {
     v1++;
  }

if ( p[i] == 'e' )
  {
     v2++;
  }

if ( p[i] == 'i' )
  {
     v3++;
  }

if ( p[i] == 'o' )
  {
     v4++;
  }

if ( p[i] == 'u' )
  {
     v5++;
  }

if ( p[i] == 'A' )
  {
     v6++;
  }

if ( p[i] == 'E' )
  {
     v7++;
  }

if ( p[i] == 'I' )
  {
     v8++;
  }

if ( p[i] == 'O' )
  {
     v9++;
  }

if ( p[i] == 'U' )
  {
     v10++;
  }

else
continue;
}

printf ( "a = %d e = %d i = %d o = %d u = %d
            A = %d E =…

Sample C Program To Accept A String & Display Number Of Vowels.

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

char vowels(char *p);

void main()
{

char str[10];
clrscr();
printf(" \n \n Enter the string: \t ");
gets(str);
vowels(str);
getch();

}

char vowels(char *p)
{

int i,l,v=0;
l = strlen(p);
printf(" \n \n The number of vowels in the string is: \t ");

for(i = 0 ;i < l ; i++)
  {
     if ( p[i] == 'a' || p[i] == 'e' || p[i] == 'i' || p[i] == 'o' || p[i] == 'u' ||
          p[i] == 'A' || p[i] == 'E' || p[i] == 'I' || p[i] == 'O' || p[i] == 'U' )
       {
          v++;
       }
     else
          continue;
  }

printf("%d",v);
return 1;

}

OUTPUT: 

Enter the string: Dinosaur
The number of vowels in the string is: 4


ALSO READ:

Sample C Program To Accept A String & Display Vowels.

Sample C Program To Accept A String & Display In Reverse.

Sample C Program To Accept A String & Display Its Alternate…

Sample C Program To Accept A String & Display Vowels.

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

char vowels(char *p);

void main()
{

char str[20];
clrscr();

printf(" \n \n Enter the string: \t ");
gets(str);

vowels(str);
getch();

}

char vowels(char *p)
{

int i,l;
l = strlen(p);

printf(" \n \n The vowels in the string are: \t ");
for( i = 0; i < l; i++ )
 {
  if(p[i] == 'a' || p[i] == 'e' || p[i] == 'i' || p[i] == 'o' || p[i] == 'u'|| p[i] == 'A' || p[i] == 'E' || p[i] == 'I' || p[i] == 'O' || p[i] == 'U')
   {
     printf("%c",p[i]);
   }
  else
     continue;
 }
return 1;

}

OUTPUT: 

Enter the string: Malayalam
The vowels in the string are: a a a



ALSO READ:

Sample C Program To Swap Two Strings Using strcpy() Function.

Sample C Program To Sort A Given Number Of Strings Using strcmp() Function.

Sample C Program To Display Array Of Strings.

Sample C Program To Convert String To An Integer Using atoi(…

Sample C Program To Accept Two Strings & Display Combination Of Two Strings.

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

void comb(char *p1, char *p2);

void main()
{

char str1[10];
char str2[10];

clrscr();
printf(" \n \n Enter first string:\t ");

fflush(stdin);
gets(str1);

printf(" \n \n Enter second string: \t ");
fflush(stdin);

gets(str2);
comb(str1,str2);

}

void comb(char *p1, char *p2)
{

int i, l1, l2;
l1 = strlen(p1);
l2 = strlen(p2);

printf(" \n \n The combination is: \t ");
for( i = 0; i < l1; i++ )
 {
  printf(" %c ",p1[i]);
 }

for( i = 0; i < l2; i++ )
 {
  printf(" %c ",p2[i]);
 }

getch();
}


OUTPUT: 

Enter first string: Rahul
Enter second string: Kulkarni
The combination is: RahulKulkarni


ALSO READ:

Sample C Program To Swap Two Strings Using strcpy() Function.

Sample C Program To Sort A Given Number Of Strings Using strcmp() Function.

Sample C Program To Display Array Of Strings.

Sample C Program To Convert String To An Integer Using atoi() Function.

Sample C Program To Fi…

Sample C Program To Accept Two Strings & Display The Largest String.

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

void largstr(char *p1,char *p2);

void main()
{

char str1[10];
char str2[10];
clrscr();
printf(" \n \n Enter first string: \t ");

fflush(stdin);
gets(str1);
printf(" \n \n Enter second string: \t ");

fflush(stdin);
gets(str2);
largstr(str1,str2);

}

void largstr(char *p1, char *p2)
{

int l1, l2, i;
l1 = strlen(p1);
l2 = strlen(p2);

printf(" \n \n The largest string is: \t ");
if(l1 > l2)
 {
  for(i = 0; i < l1; i++ )
   {
     printf(" %c ",p1[i]);
   }
 }
else
 {
  for(i = 0; i < l2; i++ )
   {
      printf("%c",p2[i]);
   }
 }
getch();

}

OUTPUT: 

Enter first string: rahul
Enter Second String: ankush
The largest string is: ankush

ALSO READ:

Sample C Program To Swap Two Strings Using strcpy() Function.

Sample C Program To Sort A Given Number Of Strings Using strcmp() Function.

Sample C Program To Display Array Of Strings.

Sample C Program To Convert String To An…

Sample C Program To Accept A String & Display It's Alternate Characters In Reverse.

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


char realt(char *p);
void main()
{

char str[10];
clrscr();
printf(" \n \n Enter the string: \t ");

gets(str);
realt(str);
getch();

}

char realt(char *p)
{

int i,l;
l = strlen(p);

printf(" \n \n Alternate characters in reverse: \t ");
for(i = l - 1; i >= 0; i -= 2)
 {
  printf(" %c ",p[i]);
 }
return 1;

}


OUTPUT:

Enter the string: pneumonia
Alternate characters in reverse:
a
n
m
e
p


ALSO READ:

Sample C Program To Swap Two Strings Using strcpy() Function.

Sample C Program To Sort A Given Number Of Strings Using strcmp() Function.

Sample C Program To Display Array Of Strings.

Sample C Program To Convert String To An Integer Using atoi() Function.

Sample C Program To Find The Length Of A String.




Sample C Program To Accept A String & Display It's Substring.

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

char substr(char *p, int s, int n);

void main()
{

char str[50];
int start,no_of_chars;
clrscr();

printf(" \n \n Enter the string: \t ");
gets(str);

printf(" \n \n Enter start position for substring: \t ");
fflush(stdin);

scanf(" %d ",&start);
printf(" \n \n Enter number of characters: \t ");
fflush(stdin);

scanf(" %d ",&no_of_chars);
substr(str,start,no_of_chars);
getch();

}

char substr(char *p, int s, int n)
{

int i;
printf(" \n \n The substring is: \t ");
for( i = s - 1; i < n;i++)
 {
  printf("%c",p[i]);
 }
return 1;
}


OUTPUT: 

Enter the string: Please Mention Your Address:
Enter start position for substring: 20
Enter number of characters: 7
The substring is: Address


ALSO READ:

Sample C Program To Swap Two Strings Using strcpy() Function.

Sample C Program To Sort A Given Number Of Strings Using strcmp() Function.

Sample C Program To D…

Sample C Program To Accept A String & Display Alternate Characters In Either Case.

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

char altcase(char *p);

void main()
{

char str[20];
clrscr();
printf(" \n \n Enter the string: \t ");
gets(str);
altcase(str);
getch();

}

char altcase(char *p)
{

printf(" \n \n Alternate characters of string are: \t ");
while(*p)
 {
   if (*p >= 'A' && *p <= 'Z')
    {
      *p = *p + 32;
    }
   else if (*p >='a' && *p <='z')
    {
      *p = *p - 32;
    }
   printf("%c",*p);
   p += 2;
 }
return 1;
}


OUTPUT: 

Enter the string: LnTInfotech
Alternate Characters of string are: L T n o e h


ALSO READ:

Sample C Program To Swap Two Strings Using strcpy() Function.

Sample C Program To Sort A Given Number Of Strings Using strcmp() Function.

Sample C Program To Display Array Of Strings.

Sample C Program To Convert String To An Integer Using atoi() Function.

Sample C Program To Find The Length Of A String.



Sample C Program To Accept A String & Display Its Alternate Characters.

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

char alt(char *p);

void main()
{

char str[10];
clrscr();
printf(" \n \n Enter the string: \t ");
gets(str);
alt(str);
getch();

}

char alt(char *p)
{

int j,l;
l = strlen(p);
printf(" \n \n Alternate characters of the entered string are: \t ");
for(j = 0; j <= l - 1; j = j + 2)
  {
    printf("%c",p[j]);
  }
return 1;
}


OUTPUT:

Enter the string: BODYGUARD
Alternate characters of the entered string are:
B D G A D


ALSO READ:

Sample C Program To Swap Two Strings Using strcpy() Function.

Sample C Program To Sort A Given Number Of Strings Using strcmp() Function.

Sample C Program To Display Array Of Strings.

Sample C Program To Convert String To An Integer Using atoi() Function.

Sample C Program To Find The Length Of A String.



Sample C Program To Accept A String & Display In Reverse.

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


char reverse(char *p);

void main()
{

int i;
char str[10];
clrscr();
printf(" \n \n Enter the String: \t ");
gets(str);
reverse(str);
getch();

}

char reverse(char *p)
{

int j,l;
l = strlen(p);
printf(" \n \n String in reverse is: \t ");
for(j = l - 1; j >= 0; j--)
{
printf("%c",p[j]);
}
return 1;

}


OUTPUT:

Enter the string: Kolaveri
String in reverse is: irevalok


ALSO READ:

Sample C Program To Swap Two Strings Using strcpy() Function.

Sample C Program To Sort A Given Number Of Strings Using strcmp() Function.

Sample C Program To Display Array Of Strings.

Sample C Program To Convert String To An Integer Using atoi() Function.

Sample C Program To Find The Length Of A String.



Sample C Program To Accept A String & Display It.

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

char string( char str2[10] );

void main()
{

int i;
char str1[10];
clrscr();

printf(" \n \n Enter The String: \t ");

for( i = 0; i <= 9; i++ )
    scanf(" %c ", &str1[i] );

string( str1 );
getch();

}


char string(char str2[10])
{

int j;
printf(" \n \n The String Is \t ");

for( j = 0; j <= 9; j++ )
    printf(" %c ", str2[j] );

return 1;

}


OUTPUT:

Enter The String: Interview

The String Is: Interview


ALSO CHECKOUT:

-- C Program To Find The Length Of A String.
-- C Program To Concatenate Two Strings.
-- C Program To Compare Two Strings.
-- C Program To Swap Two Strings.

-- C Program To Swap Two Strings Using strcpy() Function.

-- C Program To Sort A Given Number Of Strings Using strcmp() Function.
-- C Program To Check Whether A String Is Palindrome Or Not.
-- C Program To Print The Reverse Of A String.
-- C Program To Join Two Strings.
-- C Program To Display Array Of Strings.


-- C Program To Convert Str…

Data Structure & Algorithm Interview Questions And Answers - Part X.

Here, are some sample questions based on "Data Structures". Read it carefully as these questions will help you in cracking any interview.


46) What do you mean by Polish string ?

Answer: Polish string refers to the notation in which the operator symbol is placed either before its operands (prefix notation) or after it operands (postfix notation). The usual form, in which the operator is placed in between the operands is called infix notation.


47) What do you mean by an infix, postfix and prefix expression ?

Answer: An expression where operators are placed in between the operands is called a infix expression.
E.g.: A + B

An expression where operators are placed after the operands is called a postfix expression.
E.g.: AB+

An expression where operators are placed before the operands is called a prefix expression.
E.g.: +AB


48) What is the evaluation order according to which an infix expression is converted to postfix expression ?

Answer: The evaluation order is:

I. Brackets or Pa…

Data Structure & Algorithm Interview Questions And Answers - Part IX.

Here, are some sample questions based on "Data Structures". Read it carefully as these questions will help you in cracking any interview.


41) What do you mean by bubble sort ?

Bubble sort is an array sorting technique in which the adjoining values are compared and exchanged if they are not in the proper order. The process repeats until the entire array is sorted.


42) What is insertion sort ?

In insertion sort, each successive element is picked from its position and inserted at an appropriate position in the previously sorted array.


43) Differentiate between the different types of linked lists ?

Linked lists are of two types viz, singly linked or one-way lists and doubly linked or two-way lists. Singly linked lists contain node with single pointer pointing to the next node in sequence whereas doubly linked lists contain two pointers, one pointing to previous node and other pointing to the next node in sequence.


44) What do you mean by ‘pushing’ and ‘popping’ with regard to stack…

Data Structure & Algorithm Interview Questions And Answers - Part VIII.

Here, are some sample questions based on "Data Structures". Read it carefully as these questions will help you in cracking any interview.


36) What are the differences between linear search and binary search ?

The differences between linear and binary searches are:

Binary search carries out the searching process with the minimum number of comparisons but linear search does not guarantee lesser number of comparisons.To save on time and comparisons, binary search is much more beneficial than linear search.Binary search can work for only sorted arrays whereas linear search can work for both sorted as well as unsorted arrays.


37) State the condition(s) under which binary search is applicable ?

The conditions for binary search are:

The list must be sorted.Lower bound and upper bound, and the sort order of the list must be known.

38) What are the advantages of linked lists over arrays ?

Linked lists overcome the drawbacks of arrays as in linked lists, number of elements need not be prede…

Data Structure & Algorithm Interview Questions And Answers - Part VII.

Here, are some sample questions based on "Data Structures". Read it carefully as these questions will help you in cracking any interview.


31) List the basic operations which can be performed on data structures ?

The basic operations which can be performed on data structures are:

Insertion: Addition of new element into a data structure.Deletion: Removal of a data element from a data structure.Searching: Searching for and finding a specified data element in a data structure.Traversal: Traversing along a data structure and processing all the data elements of it.Sorting: Arranging data elements of a data structure in a specified order.Merging: Combining elements of two similar data structures to form a new data structure of same type.

32) How can you calculate the size of an array, given the upper and lower bounds of the array ?

When upper bound and lower bound of an array are given, its size is calculated as:

Array size (length) = UB – LB + 1

Where UB = Upper bound and LB = lower …

Data Structure & Algorithm Interview Questions And Answers - Part VI.

Here, are some sample questions based on "Data Structures". Read it carefully as these questions will help you in cracking any interview.


26) What are the different types of arrays?

Arrays are of different types namely one-dimensional arrays, two-dimensional arrays and multi-dimensional arrays. One-dimensional arrays comprise of finite homogeneous elements while multi-dimensional arrays comprise of elements, each of which is itself an array.


27) What do you mean by the base address of an array?

In memory, one-dimensional arrays are implemented by allocating a sequence of addressed locations so as to accommodate all its elements. The starting address of the very first element of the array is called base address of the array.


28) Give the formula to calculate the address of any element in an array, when the length of the array along with its base address and size of the element are given ?

The formula to calculate address of any element in an array is:

Address of the element wit…

Data Structure & Algorithm Interview Questions And Answers - Part V.

Here, are some sample questions based on "Data Structures". Read it carefully as these questions will help you in cracking any interview.


21) What advantages and disadvantages, do you think does a circular singly linked list have over a non-circular singly linked list?

A circular singly linked list is advantageous over a non-circular singly linked list because the former helps in sequencing from any node to any other node in the list. And the disadvantage is that it can make the end of the list more difficult to detect than if the last node contained a NULL next pointer.


22) Give the similarities between queues and stacks ?

Both queues and stacks are special cases of linear lists.Both can be implemented as arrays or linked lists.

23) Differentiate between queues and stacks ?

The differences between queues and stacks are:

A stack is a LIFO list while a queue is a FIFO list.There are no variations of stack. A queue, however, may be circular or dequeue.

24) To perform recursion, whi…

Data Structure & Algorithm Interview Questions And Answers - Part IV.

Here, are some sample questions based on "Data Structures". Read it carefully as these questions will help you in cracking any interview.


16) What Is A Circular Queue ?

Circular queues are the queues implemented in circular form rather than a straight line. In these types of queue, the last element is always followed by the first element.


17) What Do You Mean By The Terms ‘Overflow’ & ‘Underflow’ In Data Structures ?

Overflow and Underflow are two states in data structures when further insertions and deletions respectively are not possible in the data structure.

Overflow refers to inserting a node when no memory is available and Underflow refers to deleting from an empty list.


18) What Is Meant By Dequeue ?

Queues in which elements can be added or removed at either end but not in the middle are called dequeues. There are two types of dequeue namely input restricted dequeue and output restricted dequeue.


19) What Do You Mean By Garbage Collection In Data Structures ? What Role D…

Data Structure & Algorithm Interview Questions And Answers - Part III.

Here, are some sample questions based on "Data Structures". Read it carefully as these questions will help you in cracking any interview.


11) What Is A Stack ?

Stack data structure refers to the lists stored and accessed in a special way, where LIFO or Last in First Out technique is followed. In stacks, insertions and deletions take place only at one end, called the top. Stack is similar to a stack of plates or a stack of CDs arranged vertically. In either stacks, objects, i.e. plates or CDs are inserted or removed only from the top of the stack.


12) What Is A Queue ?

Queue data structure is a FIFO or First in First Out list, where insertions take place at the rear end of the queue and deletions take place at the front end of the queue. Queue is much the same as a line of people waiting for their turn to vote, or a queue at a railway station. The first person will be the first in the queue and a new person can join the queue at the rear end of it.


13) What Are Linked Lists ?

Link…

Data Structure & Algorithm Interview Questions And Answers - Part II.

Here, are some sample questions based on "Data Structures". Read it carefully as these questions will help you in cracking any interview.


6) What Are Non Linear Data Structures ?

Non linear data structures are multi level data structures. Examples of non linear data structure are trees and graphs. In such non linear data structures, the elements share a hierarchical relationship among themselves rather than forming a sequence.


7) Differentiate Between Data Types & Data Structures ?

A data type is a named group of data with similar characteristics and behavior, E.g.: Integer, real, Boolean, character etc.

A data structure is a named group of data of different data types, organized in a particular format and characterized by specific operations that can be performed on it. E.g.: Queues, arrays, trees etc.


8) List Four Major Operations On Linear Data Structures ?

Four major operations performed on linear data structures are:

Searching: Refers to searching for a given ITEM in …

Data Structure & Algorithm Interview Questions And Answers - Part I.

Here, are some sample questions based on "Data Structures". Read it carefully as these questions will help you in cracking any interview.


1) What Is Data Structure?

A named group of data, of different data types, which can be processed as a single unit is referred to as a data structure. Data structures have well-defined operations, behavior and properties. Arrays, stacks, queues, trees are all examples of data structures.


2) What Is The Need For Data Structures In Programming?

There are various situations in real life when there is need to treat a group of different data types as a single unit.

For example, a record in a file has several fields of different data types and the entire record may be required to be processed in one unit. In such a case, data structures are essential to combine different data types and process them together.


3) What Are The Different Data Types Which A Data Structure May Comprise Of?

Data structures contain mainly three different data types:

Pri…

Sample C Program On Strings Into Array Of Pointers

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

#define S 4
main()
{

char*arr_str[S];
char temp[20];
int i, n, len;
clrscr();

for( i = 0; i < S; i++ )
{
printf(" Enter a string %d\n ", i + 1);������������������������…

Sample C Program On Pointers & 2 - Dimensional Array.

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

void input(int**, int, int);
void show(int**, int, int);

main()
{

int a[3][3];
int row = 3, col = 3;
clrscr();

input(( int** )a, row, col);
show(( int** )a, row, col);

getch();
return 0;

}

void input(int **p, i…