Tuesday, May 6, 2008

Basic C programming answers

1)Program to find number of 1s and zeros in given integer.
Find the answer here http://gucatheprogrammer.blogspot.com/2007/10/simple-yet-useful-c-programs.html

2)Write a C program to check whether machine is Big endian OR little endian
#include

int main()
{
unsigned int n = 1;
char *p;

p = (char*)&n;
if (*p == 1)
printf("Little Endian\n");
else if (*(p + sizeof(int) - 1) == 1)
printf("Big Endian\n");
else
printf("What the crap?\n");

return 0;
}
3)C program to Convert decimal to binary
Find the answer here http://gucatheprogrammer.blogspot.com/2007/10/simple-yet-useful-c-programs.html

4)C program to do STRCPY without using strcpy
I will write just the function :
char * mystrcpy(char * dest,const char *src)
{
char *temp = dest;
while ((*dest++ = *src++) != '\0')
return temp;
}

5)C program to STRCAT without using strcat
char * mystrcat(char * dest, const char * src)
{
char *temp = dest;
while (*dest)
dest++;
while ((*dest++ = *src++) != '\0') ;
return temp;
}

6)Write a C macro which returns number of seconds in year
This is too general. This is just to check guy knows about the MACRO and its syntax.
#define NUMER_OF_SECONDS_YEAR (365*24*60*60)

7)C program to find sum of digits of any given integer number .
#include
int add_digits(int a);
main()
{
int a ;
printf("Enter the number\n");
scanf("%d", &a);
printf("Sum of digits = %d\n", add_digits(a));
}
int add_digits(int num)
{
int sum = 0;
while(num)
{
sum += num%10;
num /=10;
}
return sum;
}

8)C program to fine leap year or not
This is just to check how quick he can write ..
Better would be macro or function.
#include
main()
{
int year;
printf("Enter the year\n");
scanf("%d", &year);
if(year % 4 == 0){
printf("Given year is leap\n");
} else {
printf("Given year is NOT leap\n");
}
}

9)C program to swap two variables (using pointers), without using temp variable.
#include
void swap(int *p1, int *p2);
main()
{
int a, b;
printf("Enter the values for a and b\n");
scanf("%d%d",&a,&b);
swap(&a, &b);

printf("a = %d\n and b = %d\n", a, b);
}

void swap(int *p1, int *p2)
{
*p1 = *p1 + *p2;
*p2 = *p1 - *p2;
*p1 = *p1 - *p2;
return;

}

10)C program to find sum of given Array.
#include
int arr_sum(int *a, int size);
main()
{
int a[10] = {1,2,3,4,5,6,7,8,9,10};
int sum = arr_sum(a,10);
printf("SUM = %d\n", sum);
}
int arr_sum(int *a, int size)
{
int sum = 0, i;
for(i =0; i
#define MIN(a,b) ((a>b)?b:a)
main()
{
int a=100, b=20;
printf("MIN = %d\n", MIN(a,b));

}

The below ones are left as exercise to students :) .. Actually I got bored to write :)
12)C program to find largest of three numbers
13)C program to store data for 10 student info
14)Write all infinite loops u can think off

Sunday, March 23, 2008

Campus to Corporate- 3

Since many of freshers fail to answer simple HR question, I though of making a single page for most frequently asked questions and their answers. I have couple of the links, which I found to be useful. Spend some time in browsing some good stuff :) .. Just kidding :) ..

Please have a look at the following links

http://hitechskill.com/HR-Interview-Questions/display.jsp?type=HR&page=1

The below one is not that good.... But worth visiting once

http://www.yuvajobs.com/hr-questions.asp

I will come up with my answers and update this page asap. Keep visiting this page.

Tuesday, March 4, 2008

Campus to Corporate Gateway-2

OPERATING SYSTEM BASICS
---------------------------------------
1)Explain the basic architecture of OS(Kernal, shell, user apps etc)
2)The same above question can be asked to trace the OS flow for simple commands like "ls -l"
3)What is process?
4)What is thread ?
5)what are the differences b/w process and thread?
6)What are the different states of process?
7)Explain the basics of scheduling? May be by taking simple round robin algorithm
8)What are interrupts?
9)what are different types of IPC mechanism available in the OS?
10)Difference between mutex and semaphore?
11)What is deadlock and how do we can avoid it?
12)Small shell script writting..
13)What is real time operating system?
14)What is the OS you have used for academic projects and why only that?
15)what is the difference between virtual memory and physical memory ??

Tuesday, February 26, 2008

Campus to Corporate Gateway

This is my effort to consolidate FAQ for the freshers. The most common things on which freshers can be tested is through logical analysis. In spite the candidate clears the test, he has to face the technical interview. In most of the technical interviews freshers will be judged on the basis of the basics he knows.

To test the basics interviewer can choose any of the following.

C concepts and programming
Operating System Basics
C++ programming
Computer Networks
Microprocessors or Micro controllers.

Even though candidate is always given to the choice to choose his favorite subject, it is not only the criteria to select the candidate, Meaning even though candidate is good at his favorite subject interviewer always makes sure what he knows apart from that and exactly that's where other subject peek in.

I have tried my best to list down most probable questions in each area. If you them useful give a comment else update the missing info through comments :)

Let us see Fresh C :)
------------------------
1)Program to find number of 1s and zeros in given integer.
2)Write a C program to check whether machine is Big endian OR little endian
3)C program to Convert decimal to binary
4)C program to do STRCPY without using strcpy
5)C program to STRCAT without using strcat
6)Write a C macro which returns number of seconds in year
7)C program to find sum of digits of any given integer number .
8)C program to fine leap year or not
9)C program to swap two variables (using pointers), without using temp variable.
10)C program to find sum of given Array.
11)Write Macro to return minimum of two numbers
12)C program to find largest of three numbers
13)C program to store data for 10 student info
14)Write all infinite loops u can think off

Here is the most critical part, most of the freshers fail to undersatnd or answer this. If they answer, assume that he is good in C and try to interview him on some other basics.
15)a) An integer ->int a;
b) A pointer to an integer -> int *a;
c) A pointer to a pointer to an integer -> int **a;
d) An array of 10 integers -> int a[10];
e) An array of 10 pointers to integers -> int *a[10];
f) A pointer to an array of 10 integers-> int (*a)[10];
g) A pointer to a function that takes an integer as an argument and returns an integer -> int (*fun)(int)
h) An array of ten pointers to functions that take an integer argument and return an integer int (*fun[10])(int)


16)Difference between struct n union
17)What are uses of keyword "static" ?
18)Test knowledge on const
const int a;
int const a;
const int *a;
int * const a;
int const * a const;

19)C Program to set/clear 3rd bit in given int
20) What is self referntail structure
21)List down all file operation calls u ve used so far.
22) Give them small programs n ask the output
1) Check if catches seg faults
2)Relations operators (Especially logical operators)
3)const value increament/decrement rules.
4)extern initialzation
5)recursive functions
6)pointer operations

23) Ask him to explain basic data types and derived data types.
24)C program to remove the duplicate elements of the array.
25)C program to find the simple interst.(Or any formula)

Networking Basics
-----------------------
These questions will be asked to check the potential of the candidate, if he chooses his favorite subject as computer networks OR if the company is core networking company.
1)Different types of ethernet and their speed.
2)IP addres basics (classes etc)
3)Wireless and wired connections
4)Difference between router/bridge/switch
6)TCP/IP model explaination
7) OSI model (layers explaination)
8)CSMA/CD algorithm
9)TCP/UDP difference or try to get from him what are all he/she knows about it.
10)What is DHCP/DNS?
11)Ethernet header. (If he can explain MAC address alone,that is sufficient)
12) Tunneling theory.
13)Routing table - discovery (Any of the congestion algorithm)
14)Favourite layer and its operation
15)server/client model
16)Network topolopy and their selection
17)How do u choose the port number for any of the protocol
18)Any of the application layer protocol
19)Basics about the LAN
20)Some random problem about the network and try to see how he approaches towards it.

This will be updated on different subjects, when I find the time :)