Interview Q & A 8
1. write a code for removing repeated digits in a number?
ex : number = 45678678 here the digits 6,7,8 has to be removed.
2. write a code to search the largest element in the array of your choice?
3. write a program to convert the integer string to number using atoi function.?
4. write a source code to find the sum of 1/3+1/5+1/7+ ....+1/n using recursive function?
5. write a code for linked list print function in reverse order?
6. what is the difference between address of variable and address of ponter variable,
explain using an example?
7. write a source code for insert a char/word/substring into a string?
8. can we return multiple values from the function explain with an example?
9. what is the output for the below code?
static int k= 8;
10. what are the errors in the below source code?
11. explain for the below code, the memory allocated is safe or not?
struct person *per;
per=(struct per*)malloc(sizeof(struct person));
12. explain the memory is safe for the below mentioned code?
struct person *per;
per=(struct person*)malloc(sizeof(struct person)*100);
char pername = "ptinstitute.in" ;
per = *pername;
13 what is the output for the below code explain?
printf("%d %d ",strlen(name),strlen(name));
printf(" %d %d",sizeof(name++),sizeof(name));
14. what is the output for the below program explain?
printf("%c %x %d",p,q,r);
15. what is the output for the below code explain?
16. what is the output for the below program?
static int m=3;
10. no errors.
output: 9 function
11. safe, because memory is allocated to pointer per.
12. here memory allocated to per ,
then per = *pername //it stores the 'p' in the per variable.
we copying the ascii value of p to pointer p which gives runtime error.
the allocated memory is not freed, so memory leakage happened here.
13. the prototype of strlen is
size_t strlen ( const char * str );
we need to pass the address of the string to find the length.
in the program we passing strlen with name, we are passing without index.
we suppose to pass the address of the string. that is why it gives compile time error.
14. ascii character for 1, 1 0
15. it gives an lengthy loop, in the for loop we incrementing p++ in condition checking position,
p++ doing continuously and the loop stops after p=0.
16 It gives an runtime error like stack over flow issue.
here we are not exiting the recursive function main, it is calling continuously main recusively.