#include<stdio.h> int main() { int i, j, temp, arr[10]; printf(“Enter the number with some repeated number\n”); for(i
Category: Most Important Interview Questions In C
Most important and frequently asked C interview questions
Q24 Write a C program to convert from decimal to binary, octal, or hex number system.
#include<stdio.h> void decimal_to_any_base(int number, int base) { int i, x, digits[1000], flag; i = 0; while(number)
Q23 Write a C program which produces its own source code as its output.
#include<stdio.h> int main() { FILE *fptr; char chr; fptr = fopen(__FILE__,”r”); do{ chr= getc(fptr); putchar(chr); } while(chr!=EOF); fclose(fptr); return 0;
Q22 How to add sum the digits of a given number in single statement?
Twisted question from interviewer, but not difficult. for(; num > 0; sum += num%10, num /= 10); printf(“Sum = %d\n”,sum);
Q21 Write your own program to implement the atoi() function.
What atoi() function does? atoi() function is used to convert a string to an integer #include int own_atoi(const char *str)
Q20 Write your own function of memset().
memset() function is used to initialize a block of memory to a specified value. User defined function of memset(). #include<stdio.h> #include<string.h>
Q19 Write your own function of memcmp().
memcmp() function is used to perform byte by byte comparison. Given below user defined memecmp() function. #include<stdio.h> #include<string.h> #include<stdlib.h> int
Q18 Write your own function of memmove().
User defined function of memmove(). #include<stdio.h> #include<string.h> #include<stdlib.h> void own_memmove(void *to, const void *from, int n) { unsigned char
Q17 Write your own function of memcpy().
User defined function of memcpy(). #include<stdio.h> #include<string.h> #include<stdlib.h> void own_memcpy(void *to, void *from, int n) { while(n- -)
Q16 What is the difference between memcpy and memmove.
Hmm friends this is interviewer’s favourite question. Interviewer wants to know, how you handle byte stream. Prototype of memcpy() void
User defined function of strcmp()
User defined function of strcmp() strlen is used to compare two strings. If return value is zero means both strings are
User defined function of strncpy()
User defined function of strcpy() strncpy is used to copies first n character of a string to another. Prototype of
User defined function of strcpy()
User defined function of strcpy() strcpy is used to copies a string to another. Prototype of strcpy() function : char*
Q15 Write your own C program of strlen(), strcpy(), strncpy() and strcmp()
Interview can ask write your own program or user defined function of strlen(), strcpy(), strncpy(). User defined function of strlen() strlen