75 Posted Topics

Member Avatar for mackieben04

you are using getch(), clrscr() all of which are part of <conio.h> which you haven't included. It is also suggested not to use <conio.h> as it is not standard and not supported in many compilers. You are returning 0 in line 272, but your main function's return type is void. …

Member Avatar for mackieben04
0
221
Member Avatar for mrprassad

What do you actually intend to do? When I ran your code, for an input "abcde" I got an output "edcba". What is the problem you're finding with swap()? Just one piece of advice. Avoid writing codes like those in line 19 and 22. "++" operator may give different results …

Member Avatar for Narue
0
155
Member Avatar for srinidelite
Member Avatar for gdubz

If it's only for read only purpose, you can use your original string itself as an array of characters terminated with '\0'. [CODE] string myString = "hello world"; const char *myArray; myArray = myString.c_str(); [/CODE] Otherwise create a copy and do read/write [CODE] string myString = "hello world"; const char …

Member Avatar for subith86
0
129
Member Avatar for bluewhale628

check line 35. Syntax error. Also, I doubt int cardNumber is not initialized anywhere.

Member Avatar for Lerner
0
589
Member Avatar for guccimane

[QUOTE=guccimane;1734038]I thought everytime I allocated memory using 'new', I am suppose to free the memory using 'delete'.[/QUOTE] You are right, but you try to use the memory allocated to the linked list after deleting it. This causes the problem. So do a delete only after you are finished playing with …

Member Avatar for subith86
0
1K
Member Avatar for DarkPyros

[QUOTE=DarkPyros;1732403] the scanf at the end is to keep the program on the screen after it executes and displays the output..[/QUOTE] Use getch() function defined in conio.h thereby you can avoid using scanf() to hold the output screen. And before you proceed, you need to verify the sides belong to …

Member Avatar for WaltP
0
205
Member Avatar for srinidelite

To access element at a[5][4][9][20], use [CODE]printf("%d", *(*(*(*(a+5)+4)+9)+20));[/CODE]

Member Avatar for Moschops
0
79
Member Avatar for pororo11
Member Avatar for L7Sqr
0
5K
Member Avatar for moonw3ll

first of all if you intend to use a[] as a string, it should end with '\0' character.

Member Avatar for moonw3ll
0
236
Member Avatar for shanki himanshu

the function pow() returns double. So you can use double to hold the value. [CODE] using namespace std; int main() { double i; i = pow(2,1000); cout<<i<<endl; //prints 1.07151e+301 i = i*4; cout<<i<<endl; //prints 4.28603e+301 i = pow(i,((double)1/1002)); cout<<i<<endl; //prints 2 return 0; } [/CODE]

Member Avatar for subith86
0
126
Member Avatar for gourav1

assume the string is abcde first group "abc" and "de" separately "abc" is the fixed part and "de" is the variable part. keeping "abc" fixed, there are two possibilities with which you can arrange "de" [I]Iteration 1[/I] abc|de --- (1) abc|ed --- (2) In the next iteration, take out the …

Member Avatar for subith86
0
106
Member Avatar for subith86

Hi all, Sorry if this is a stupid question. Assume I have a code like this. [CODE] char *temp = "poiuytrewq"; std::cout<<*temp<<std::endl; //should print p function(temp); std::cout<<*temp<<std::endl; //should print i [/CODE] Basically my function() in the above snippet increments the pointer twice so that temp point to 'i' now. I …

Member Avatar for subith86
0
179
Member Avatar for subith86

Hi all, Here is a short summary of my piece of code. [code] double availableUnits = calculateAvailableUnits(some arguments); int minimumRequiredUnits = getMinimumRequiredUnits(some arguments); std::cout<<"minimumRequiredUnits = "<<minimumRequiredUnits<<std::endl; //prints 30 std::cout<<"availableUnits = "<<availableUnits<<std::endl; //prints 30 if (availableUnits < minimumRequiredUnits) { //throw exception; } //rest of the code [/code] Even though both variables …

Member Avatar for Tumlee
0
204
Member Avatar for subith86

Hi all, I'm trying to get an octal number from console and store it in an int variable using scanf. Here is my code. [CODE] int n; scanf("%i", &n); printf("\nEntered number in dec = %d", n); printf("\nEntered number in hex = %x", n); printf("\nEntered number in oct = %o", n); …

Member Avatar for subith86
0
117
Member Avatar for andyhunter

You can use [CODE]Collections.sort(yourArrayList);[/CODE] But there is some work you need to do. You have to implement Comparable interface in your class. There will be a method called compareTo (Object o) which you need to override. Here you are free to code how you should sort (using first name or …

Member Avatar for thekashyap
0
152
Member Avatar for subith86

Here the value of int x is always zero. I don't know if there is any case where it is non-zero. If so pls reply. [CODE]int OperOverld::operator--(int x) { cout<<x<<endl; //always zero //some code goes here //... //... //... //atlast return some int }[/CODE]

Member Avatar for Narue
0
176
Member Avatar for subith86

Hi friends, I was understanding the concept of friend functions. I read in my book that there are two possible ways of "making friendship":cool: 1. Make a class a friend. 2. Make the method in a class a friend. I am able to write a code for the first point. …

Member Avatar for jonsca
0
2K
Member Avatar for subith86

Hi friends, One of my class member function is supposed to return an array of integers. Here's the function. [CODE]int* MyClass::getallVars() { int* a = new int; int b[] = { GetparentVar1(), GetparentVar2(), GetchildVar1(), GetchildVar2(), }; a=b; return a; }[/CODE] Is there anyway I can do this without the use …

Member Avatar for subith86
0
176
Member Avatar for subith86

Hi friends, I was trying out some inheritance related stuff and found something. I just want to know the reason why. I have a ParentClass and a ChildClass. Both have an integer named [B]commonVar1[/B]. Also both have a getter method of the same name. Here goes the code. [CODE]class ParentClassOT …

Member Avatar for template<>
0
122
Member Avatar for subith86

Hi friends, I know this is such a freak code, but out of curiosity I did it to see memory usage increase using new operator. [CODE]int main() { char* a; for (;;) { //cout<<&a<<endl; a = new char[10]; } }[/CODE] As you see line7 is commented. When i run this …

Member Avatar for subith86
0
148
Member Avatar for subith86

while i was learning about global variables I did some trials and found one problem. Here goes my code. [CODE]int cows = 10; //global variable void farm1() { int cows; cout<<"in farm1, cows="<<cows<<endl; cows++; } int main() { //cout<<"in main, cows="<<cows<<endl; farm1(); //cout<<"back in main, cows="<<cows<<endl; } [/CODE] Here line …

Member Avatar for mike_2000_17
0
189
Member Avatar for subith86

I'm trying something like this [CODE]void receiver (char* x) { cout<<x<<endl; //prints "a" cout<<*x<<endl; //prints "a" cout<<&x<<endl; //prints address of x } int main() { char p = 'a'; cout<<p<<endl; //prints "a" cout<<&p<<endl; //prints "a" receiver(&p); } [/CODE] In the main function for both p and &p, it is printing …

Member Avatar for subith86
0
322
Member Avatar for subith86

In C++ I'm able to do something like this [CODE](some_condition)? function1():function2();[/CODE] When i tried the same thing in Java it's not possible. It wants some variable to hold the result even though the return type of function1 and function2 are void. Is there any other way to do it other …

Member Avatar for subith86
0
133
Member Avatar for subith86

Here is my piece of code: [CODE] int b[2][2] = { {4,6}, {-3,0} }; int b_length = (sizeof b)/sizeof(int); int *sub_b = b[1];[/CODE] b_length will have the length of 2-D array b (4, in this case). now sub_b is the sub-array of b at row 1, which is {-3,0} Is …

0
44

The End.