ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip       Ask Questions on ANYTHING, that arise in your Daily Life at     FORUM9.COM
Google
 
Categories  >>  Software  >>  Programming Languages  >>  C
 
 


 

 
 C interview questions  C Interview Questions
 C++ interview questions  C++ Interview Questions
 VC++ interview questions  VC++ Interview Questions
 Delphi interview questions  Delphi Interview Questions
 Programming Languages AllOther interview questions  Programming Languages AllOther Interview Questions
Question
Write a program to write a given string in maximum
possibilities?
i.e str[5]="reddy";
i.e we can write this string in 120 ways 
for that write a program
 Question Submitted By :: Ram
I also faced this Question!!     Rank Answer Posted By  
 
  Re: Write a program to write a given string in maximum possibilities? i.e str[5]="reddy"; i.e we can write this string in 120 ways for that write a program
Answer
# 1
Here is an example program...

#include "stdafx.h"
#include "string.h"

int recursive(int length)
{
    if ( length <= 1 )
      return 1;
    else
      return length*recursive(length-1);
}

int main(int argc, char* argv[])
{
	char data[] = "ready";

    printf("maximum possibilities  - %d \n", recursive
(strlen(data)));
	return 0;
}
 
Is This Answer Correct ?    1 Yes 2 No
Sunil Singh
 
  Re: Write a program to write a given string in maximum possibilities? i.e str[5]="reddy"; i.e we can write this string in 120 ways for that write a program
Answer
# 2
Hi thanks for this answer
But i need all that possibilities to be printed 
If u can make that answer let me know?
 
Is This Answer Correct ?    2 Yes 1 No
Ram
 
 
 
  Re: Write a program to write a given string in maximum possibilities? i.e str[5]="reddy"; i.e we can write this string in 120 ways for that write a program
Answer
# 3
Hello dear....
sorry for my misunderstanding for the question..
please check this code it might help you..
************************************************************
#include "stdafx.h"
#include "string.h"
#include "conio.h"

#define BUFFER_SIZE 256

int fcto(int value)
{
	int result;
	
	if(value <= 1)
	{
		return 1;
	}
	else
	{
	  return (value*fcto(value-1));
	}
}
void PrintAllValues(char *ptr,int number)
{
   char backup[BUFFER_SIZE],*first, *second,*temp1;
   int loop, length;
   char result[BUFFER_SIZE];
   char temp,temp12;
   int count =0,i;
   static int serial =0;
   memset(backup,0x00, BUFFER_SIZE);
   memset(result,0x00, BUFFER_SIZE);
   memcpy(result,ptr,BUFFER_SIZE);
   memcpy(backup,ptr,BUFFER_SIZE);
   first = second = result;
   temp1 = backup;
   length= strlen(result);
   printf("\r\n%s - %d",result,serial);
   for(loop=1;loop<=number;)
   {
	  second += count;
          first += count;
          if(*(first+1) == '\0')
	  {
	        temp = result[0];
                for(i = 0 ; i < length;i++)
		{
			if(i == 0)
			{
			  temp =result[i]; 
			  result[i] = result[length-1];
			}
			else
			{
                          temp12 = result[i];
			  result[i] = temp;
			  temp = temp12;
			}
		}
		memcpy(backup,result,BUFFER_SIZE);
                first = second = result;
		count = 0;
		loop++;
		serial++;
		printf("\r\n%s - %d",result,serial);
	  }
          while((*second != '\0') && (loop <= number))
	  { 
		serial++;
		loop++;
                if(*first != *second)
		{
		  temp = *first;
		  *first = *second;
		  *second = temp;
		  second++;
		  first++;
         	  printf("\r\n%s - %d",result,serial);
		}
		else
		{
			printf("\r\n****** - %d",serial);
			second++;
		}

	  }
          memcpy(result,backup,BUFFER_SIZE);
	  first = second = result;
	  count++;	  
    }
}

int main()
{
	char *ptr = "abcdef";// enter the string
	int data1;

	data1 = fcto(strlen(ptr));
        PrintAllValues(ptr,data1);

	getch();
	return 0;
}
************************************************************

Please let me know if you face any problem.

Thanks
sunil
 
Is This Answer Correct ?    0 Yes 1 No
Sunil Singh
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
write a program that explain #define and # undef directive  1
write a program to insert an element at the specified position in the given array in c language IBM2
what will happen if you free a pointer twice after allocating memory dynamically ? Novell2
WRITE A PROGRAM IN C TO MULTIPLY TWO 2-D ARRAYS  4
what is pointer ? Kernex-Micro-Systems7
palindrome for strings and numbers----Can anybody do the prog? TCS6
What is the difference between typeof(foo) and myFoo.GetType()?  1
What are the phases in s/w developed life cycle? wat is the diff b/w stack & queue...where do we use stack  5
parkside's triangle.. create a program like this.. enter the size: 6 enter the seed: 1 output: 1 23 456 7891 23456 789123 sample2: enter the size: 5 enter the seed: 3 output: 3 45 678 9123 45678 parkside should not exceed 10 while its seed should only be not more than 9..  4
what is diff b/w huge & far & near pointer?? HCL1
How to add two numbers with using function?  3
How to receive strings with spaces in scanf()  4
what does exit() do? Cadence3
long int size a) 4 bytes b) 2 bytes c) compiler dependent d) 8 bytes HCL11
I have an array of 100 elements, each of which is a random integer. I want to know which of the elements: a) are multiples of 2 b) are multiples of 2 AND 5 c) have a remainder of 3 when divided by 7  1
without using arithmatic operator convert an intger variable x into x+1  1
dennis ritchie invented C language in AT&T bell laboratory what is the extension of AT&T?  1
what is the differance between pass by reference and pass by value. Infosys4
Sir i want e-notes of C languge of BAlaguruswami book i.e scanned or pdf file of balaguruswamy book on c language.PLEASE SEND ME on my mail id ajit_kolhe@rediff.com  4
how to create c progarm without void main()?  1
 
For more C Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com