Friday, December 27, 2013

C program to print 'xay' in place of every 'a' in a string.

This question was asked in one the technical interview( Under graduate level). This is kind of application for  'replace' feature. You can make it more accurate by putting more constraints. Ans : #include<stdio.h>int main(){int i=0;char str[100],x ='x',y='y' ;printf("Enter the string\n:");gets(str);while(str[i]!='\0'){if(str[i]=='a'){printf("%c ",x);printf("%c ",str[i++] );printf("%c ",y);}else{printf("%c...

Tuesday, December 24, 2013

How to deallocate dynamically allocate memory without using “free()” function.

NOTE: this is actually puzzle type question nobody  use it realloc() function to free the memory. But I heard, in many interviews this question had been asked. Standard library function realloc() can be used to deallocate previously allocated memory. Below is function declaration of “realloc()” from “stdlib.h” void *realloc(void *ptr, size_t size);   If “size” is zero, then...

Saturday, December 21, 2013

SCANF() - Some important features.

scanf() The scanf()is very powerful function. We can use it to scan the input but we can add something in it's arguments and make it very powerful function. Assume that we have one variable : a[100]; To read a string:  scanf("%[^\n]\n", a); // it means read until you...

Saturday, December 14, 2013

Why should u not use turbo c++ ?

I have seen that in many under graduate collages turbo c++ is still used.  But now a days it is an outdated IDE.  Please, do not use it. It is totally useless. Turbo C++ There are many recent IDEs available which has great features and no bugs like GCC or Eclipse C/C++. Now a days...