Make a combination program in C++ which will take a string and value of r as input and will generate all possible combinations
*where r is r of formula ncr
Thanks for submitting your Question
![]()
Write a C++ program to convert any infix expression to its post-fix form....
Eg-
if user enters a+b
it should print ab+
/*\
Write a C++ program to convert any infix expression to its post-fix form....
Eg-
if user enters a+b
it should print ab+
\*/
#include <iostream>
#include <iomanip>
using std::cin;
using std::endl;
using std::cout;
using std::setw;
int main()
{
int hold=0;
const int max=100;
char symbol('+');
char string[max] = {0};
char repeat('n');
char stringExp[max] = {0};
char stringSymbol[max] = {0};
int j=0;
int i=0;
int k=0;
cout << "Type any Expression to proceed" << endl;
cin.getline(string,max,'\n');
cout << endl;
cout << "Type the symbol" << endl;
cin >> symbol;
while(string[i] != '\0') //till it reaches the null character('\0')
{
if(string[i] == symbol)
{
stringSymbol[j] = string[i];
j++;
}else
{
stringExp[k] = string[i];
k++;
}
i++;
}
cout << endl;
cout << "Final Out Put " << stringExp << stringSymbol ;
cout << endl;
cin >> hold;
return 0;
}

here is some algorithmic problem. indeed this was given as a part of assignment time back. thought of sharing with you.
(a). Give a non-recursive algorithm to search a key k in a binary-search-tree (BST) with root x.
either you can implement this or provide a pseudo code.
Question
Answer
Code:/*\ Write a C++ program to convert any infix expression to its post-fix form.... Eg- if user enters a+b it should print ab+ \*/ #include <iostream> #include <iomanip> using std::cin; using std::endl; using std::cout; using std::setw; int main() { int hold=0; const int max=100; char symbol('+'); char string[max] = {0}; char repeat('n'); char stringExp[max] = {0}; char stringSymbol[max] = {0}; int j=0; int i=0; int k=0; cout << "Type any Expression to proceed" << endl; cin.getline(string,max,'\n'); cout << endl; cout << "Type the symbol" << endl; cin >> symbol; while(string[i] != '\0') //till it reaches the null character('\0') { if(string[i] == symbol) { stringSymbol[j] = string[i]; j++; }else { stringExp[k] = string[i]; k++; } i++; } cout << endl; cout << "Final Out Put " << stringExp << stringSymbol ; cout << endl; cin >> hold; return 0; }
Thx GT
VV
well well.... It should check any operator with infix expression. Not only (+) operator. Nice try,
dude + is the default operator
but you can insert any operator in run time mode.
Try with expression more than one operator....

/*\
Write a C++ program to convert any infix expression to its post-fix form....
Eg-
if user enters a+b
it should print ab+
\*/
#include <iostream>
#include <iomanip>
using std::cin;
using std::endl;
using std::cout;
using std::setw;
int main()
{
int hold=0;
const int max=100;
char string[max] = {0};
char repeat('n');
char stringExp[max] = {0};
char stringSymbol[max] = {0};
int j=0;
int i=0;
int k=0;
cout << setw(2) << "Type any Expression to proceed" << endl;
cin.getline(string,max,'\n');
cout << endl;
while(string[i] != '\0') //till it reaches the null character
{
if('9' >= string[i] && '0' <= string[i])
{
stringExp[k] = string[i];
k++;
}else
{
stringSymbol[j] = string[i];
j++;
}
i++;
}
cout << endl;
cout << "Final Out Put " << stringExp << stringSymbol ;
cout << endl;
cin >> hold;
return 0;
}
bump0

Still not correct.........
input
a/b
output
a/b
should be ab/
evidence......
![]()
/*\
Write a C++ program to convert any infix expression to its post-fix form....
Eg-
if user enters a+b
it should print ab+
\*/
#include <iostream>
#include <iomanip>
using std::cin;
using std::endl;
using std::cout;
using std::setw;
int main()
{
int hold=0;
const int max=100;
char string[max] = {0};
char repeat('n');
char stringExp[max] = {0};
char stringSymbol[max] = {0};
int j=0;
int i=0;
int k=0;
cout << "Type any Expression to proceed" << endl;
cin.getline(string,max,'\n');
cout << endl;
while(string[i] != '\0') //till it reach the null character
{
if(('9' >= string[i] && '0' <= string[i]) || ('a'<= string[i] && 'z' >= string[i]) || ('A'<= string[i] && 'Z' >= string[i]) )
{
stringExp[k] = string[i];
k++;
}else
{
stringSymbol[j] = string[i];
j++;
}
i++;
}
cout << endl;
cout << "Final Out Put " << stringExp << stringSymbol ;
cout << endl;
cin >> hold;
return 0;
}
