Arbus 25 Practically a Master Poster

Hello digitup1,
It gives zero because the time taken to do quicksort function is so small. To test that your time function works right use some loops in your code to make time delay. For example like this...

long int c;
for(c=1;c<=100000;c++)
{cout<<" ";
}
Arbus 25 Practically a Master Poster

Hello pdenman,
Reset trycount and guess in the starting of the do-while loop.

do
{trycount=0;
 guess=-1;
 while(guess!=number && trycount<8)
 //the code you posted
}
Arbus 25 Practically a Master Poster

Hello n3red,
According to your code each character in the string character array will be changed to upper case. Your code will not change the first character of the string to white space.

Arbus 25 Practically a Master Poster

just treats it as a character in a string.

Yes, I have made a mistake there. The compiler doesn't treat it as a character.

Arbus 25 Practically a Master Poster

There are some special characters like '\' which we use for '\n' etc. If we leave a space then the compiler will not recognize it as a special command and just treats it as a character in a string.

Arbus 25 Practically a Master Poster

Hello tinee,
You have given while(j-1>=0). It should have been j>=0 (note that j=j-1 should be given just before the while loop in the main) because every time after decrementing the loop checks j-1>=0(which is like decrementing twice though not decremented actually) and you get only half the values you entered.

Arbus 25 Practically a Master Poster

Welcome. As gerard4143 said you can use toupper function also.
choice=toupper(choice) would change 'r' to 'R' (if user enters 'r').

Arbus 25 Practically a Master Poster

Hello nory22,
You just have to change the condition in the if statement. For example

if(choice=='R' || choice=='r')
{ 
}
Arbus 25 Practically a Master Poster

You have given return(0) in the else part. Give it after else part.
use code tags

Arbus 25 Practically a Master Poster

Hello helmyano,
Constructors are not inherited. You have to define a constructor in the derived class also. The base class default constructor (the constructor with no parameters) and its destructor are always called when a new object of a derived class is created or destroyed.

Arbus 25 Practically a Master Poster

Hello ntrncx,
Lets take 67. 67 mod 10 will give you the ones place(7). Then divide 67 by 10. Since both are integers you will get the tenths place(6). Do this for 128 also and you will have the digits separated out.

Arbus 25 Practically a Master Poster

You should have the if statement first. For example if x<2 then it should print the value of x and then increment it. Here is an example of if else block.

int x=0;
if(x<2)
{cout<<x<<"\n";
 x=x+2;
}
else
{cout<<x<<"\n";
}
Arbus 25 Practically a Master Poster

Yes, It must be 0-4,1-3.

Arbus 25 Practically a Master Poster

After comparing the first and last letter, the function should compare the second letter and the last before letter,so on. You should preincrement start and predecrement last.

Arbus 25 Practically a Master Poster

Try --last or ++start because i think start++ will first send the value to the funciton and then increment.

Arbus 25 Practically a Master Poster

Hello ntrncx,
I think there is something wrong here testpalindrome(word,last-1,start+1); It should be last-- and start++ because last and start do not decrement or increment in last-1 or start+1

Arbus 25 Practically a Master Poster

Hello subith86,
Declare a pointer variable and use it to store the address of the char variable p.

char *b,p='a';
b=&p;
cout<<&b;
Arbus 25 Practically a Master Poster

Hello taumang,
Your if statement is missing and i think you might have got the error "Misplaced else" and your while loop will print x infinite times (x=x+1 will not be done at all). cout is given as cout<< in c++.

Arbus 25 Practically a Master Poster

What did you give in runtime? \esc or \\esc?
because it works in mine.

Arbus 25 Practically a Master Poster

You should give double slash in the array exit because single slash is used for giving '\n','\r' etc.

char exit[4]="\\esc";

"\\esc" implies that your string is \esc.

Arbus 25 Practically a Master Poster

Hello anu07,
strcmp wil return value 0 if both the strings are equal.You should check whether strcmp(temp,exit)==0. If you give if(strcmp(temp,exit)) it will break at the first time itself.

Arbus 25 Practically a Master Poster

It's not good programming style and it's a good thing to point out as the OP may not have noticed, but it'll actually work here. 0, 1, and 2 are valid char values and will be converted to integers with values 0, 1 or 2 when the function is called, so in this particular case it'll work, though it may be a bit confusing to read the code.

The problem is the while loop position (though there are some other things too).

But when i changed playerchoice to int and also cases like case 'r' etc to case 0 it worked finely on my system (I made this change in the code written in the thread which is not having while loop).

Arbus 25 Practically a Master Poster

Change playerchoice to int. Ask the user to enter 0 for rock ,1 for paper and 2 for scissors
or
have a new integer variable to pass it in the winner function.

Arbus 25 Practically a Master Poster

Hello hous3aholik,
This is where you got wrong.You declared playerchoice as a character variable and you are assigning integer 0 to it in the switch cases.

char playerChoice;
playerChoice = 0;//<--

So you cannot compare it with integer values in the winner() function and the parameters in the winner function are also integers.

Arbus 25 Practically a Master Poster

Yes,there is one method. First you store every digit of the number in an integer array and then you reverse the array and store it into another array. Check if both the arrays are equal. If equal then the number is a palindrome.

Arbus 25 Practically a Master Poster

That's what i said. The vaiables first and sixth are equal,but the varables second and fifth are not equal if the number is 123321.
second=123321%100000 =23321.
fifth=123321%100=21.

Arbus 25 Practically a Master Poster

Hello blee93,
I think there is something wrong with the ispalindrome function.
For example take 101 * 101=10201. 10201 is a palindrome. In you function isplaindrome
first will have zero if 10201 is divided by 100000. Sixth will have 1 (10201 % 10). First is not equal to sixth.
So your function will return false though 10201 is a palindrome.

Arbus 25 Practically a Master Poster

could you give your code elaborately including the definition of structure ?

Arbus 25 Practically a Master Poster

Hello mxrider,
You are using call by value method in bvolume function. So the values you give using boardLength,boardWidth, maxVolume, SqrSide will not be changed by bvolume though you declared those variables globally. Use call by reference(&) method

Arbus 25 Practically a Master Poster

It is not possible to declare an array without constant expression.

cin >> size;
 ApplicantsList a[size];//<--

Give a constant in place of size(like 100 etc)

Arbus 25 Practically a Master Poster

Hello doubleh,
If your linked lists are done by using classes, then you can use destructors to destroy the values of student with percentage less than 30.

Arbus 25 Practically a Master Poster

Hello rjbrjb777,
Try this...
Create a structure with variables dd(for day) and mm(for month). Assign the variables with the values you calculated in the function calday and return the structure instead of 'day' only.

struct cal
{float dd ,mm;
};
cal daymonth,daymonth2;
int  calday(float day,float month)
{   
  if(month==2)
  
  //code as you posted
  else
  {day = day + 334;
  }
  daymonth.dd=day;
  daymonth.mm=month;
  return(daymonth);
}

Use daymonth2 to get the structure having values of day and month that you calculated
in calday in the main function.

Arbus 25 Practically a Master Poster

Try using cin instead of gets to get character from the user in countletter function.
As gets is used to get strings and not a single character.

void countletter(char *str)
{
	int count;
	char a;
	cin>>a;
	for (;(*str)!='\0';str++)
	{
		if (*str==a)
		{
		count++;
		}
	}
	 printf("%d",count);
}
WaltP commented: Since when is cin a C input commant? -3
Arbus 25 Practically a Master Poster

Change char str to char *str and also use cin to get character in countletter function.

int main()
{
	char *str; //<--str changed to *str(pointer)
	printf("Please enter a string: ");
	gets(str);
	countletter(str);
	getch();
	return 0;
}
Arbus 25 Practically a Master Poster

Hello slygoth,
You have declared str as char str in main(). Declare it as a pointer.

Arbus 25 Practically a Master Poster

Hello Jonsca and ilinan87,
1/3 is zero since both are integers. It works fine when 1/3 given as 0.333 or 1.0/3.0 in the pow() function.

Arbus 25 Practically a Master Poster

Hello ilinan87,
You declared double geo=0. So on multiplying it with the numbers will give zero only. That's why you are not getting the required answer. Initialize geo as 1.

int geomean(int *myarray, int count)
{
	double geo = 1;
	int k;
	for(k=0; k < count; k++)
		{
			geo = geo * myarray[k];
		}	
	return geo = pow(geo,1/3);
}
Arbus 25 Practically a Master Poster

Hello charming--eyes,
The ASCII value of numeric characters start from 48 which refers to 0.Add the integer and 48,then store it in the character array.

int a[100];
char a[100];
a[0]=48+f[0];

For example if f[0] has 7,then 48 +7 = 55.So a[0] will take up the ASCII value as 55.
Put this in a loop. You will have the integers converted to string.

charming-_-eyes commented: Thanks +1
Arbus 25 Practically a Master Poster

Hello charming--eyes,
Do you want a string like "7456" if the integer array a[5] has a[0]=7,a[1]=4,a[2]=5,a[4]=6 ?

Arbus 25 Practically a Master Poster

Hello george61,
I think the problem is in the for loop which reverses the array.

for(int i = (str1size - 1); i>=0; i--)
	{
		n = (str1size - 1) - i;
		str2[n] = str1[i]; //<-- problem   
	}

I think the whole string("9009" or "2345") gets into str2[n] without getting reversed, because char *str2[20] can hold 20 strings.
str2[n] holds a string and not a character. So every time in the loop the whole string is getting into str2[n] from str[1] and not as each character.

Arbus 25 Practically a Master Poster

Hello stan2000,
The problem is in your for loop. You initialized total_pay as 0.01. Inside the for loop total_pay gets added to pay*2 which value on day 1 becomes 0.03( that is 0.01+ (0.01*2)). so the total_pay will not start from 0.01.
To start total_pay from 0.01 you should initialize it to 0.00 in
double total_pay=0.00;
Next you should initialize pay as 0.01 in
double pay=0.01;
Also change your for loop like this one below...

double pay=0.01;
double total_pay=0.00;
for (days = 1; days <= ndays; days ++) 
{total_pay=total_pay+pay;  // the total_pay which was zero first will now become 0.01 
 cout << days<<"\t"<<pay<<"\t"<<total_pay << endl;//on day 1
 pay=pay*2;  //here only the pay is doubled
}
Arbus 25 Practically a Master Poster

No.Both abort() and exit() terminate the program and not the function only. Abort() ends the program with "abnormal program termination".It indicates unsuccessful termination of program.

Arbus 25 Practically a Master Poster

Hello slygoth,
There is a simple way to do this. Initialize a character a and write a=getch(). This would not display the character entered by the user.

char a;
a=getch(); // varable a will have the character entered by the user.The character    
cout<<'*'; // entered by the user will not be displayed. cout<<'*' will put '*' 
           //appearing to the user that character that he entered was masked

Instead of a character, declare varable a as a character array. Put that in for loop(a[1]=getch etc.,). The password that the user enters is masked now.Though getch() is not in ANSI c standard it will work.

WaltP commented: We don't suggest using non-Standard C functions. getch() is not in most compilers -3
Arbus 25 Practically a Master Poster

Hello chess 2009,
Empty lines are displayed if there are multiple spaces between the two words.
Try this logic in the if else block.
If there are one or more spaces between the set of characters,the cursor should go to next line.Try this...

if(c!=' ' && c!='\t' && c!='\n' && c!='.' && c!=',' && c!=';' )
   { putchar(c);
     b=0;    //counter variable
   }
 else
 {if(b==0)       // if b==0 the cursor goes to next line.If multiple spaces are                  
  {putchar('\n');//there b becomes grater than zero.Ultimately avoiding empty spaces
  }
  b=b+1;
}
Arbus 25 Practically a Master Poster

Hello slygoth,
You should include ctype.h for using toupper.
To convert lowercase letter to uppercase you should give

pick=toupper(pick);

If the user enters 'a' you can convert it to 'A' using the above.

slygoth commented: thanks arbus +1
Arbus 25 Practically a Master Poster

Hello friends,
I am trying to play music through turbo c++.I used Irrklang sound library 1.3.0.
But while compiling i get an error saying "unable to include IK_IRRKLANGTYPES.h" and other header files. Should i change anything in header files? Is there any other way to play music in turbo c++? can anyone help me?

Thanks in advance.

Arbus 25 Practically a Master Poster

Hello Lokril,
try this....

#include<iostream.h>
#include<conio.h>
int remainder(int x,int y)
{int d,e;
 d=x/y;
 e=x-(y*d);
 return(e);
}
int main()
{.
 .
 .// code that you just posted
}
Arbus 25 Practically a Master Poster

Hello friends,

I am having a trouble with dosbox 0.72. I opened turbo c++ using dosbox and tried a program.
But it throws an error 'unable to create hello.obj'.
my program

#include<iostream.h>
#include<conio.h>
void main()
{
 cout<<"hello";
}

I gave this while opening turbo c++ in dosbox...
Z:\>mount c d:\turboc3\
Z:\>c:
C:\>tc.exe

Thanks in advance.

jingda commented: Encouragement. Continue to post well in C++ +9
Arbus 25 Practically a Master Poster

Hello friends,

I am having a trouble with dosbox 0.72. I opened turbo c++ using dosbox and tried a program.
But it throws an error 'unable to create hello.obj'.
my program

#include<iostream.h>
#include<conio.h>
void main()
{
 cout<<"hello";
}

I gave this while opening turbo c++ in dosbox...
Z:\>mount c d:\turboc3\
Z:\>c:
C:\>tc.exe

Thanks in advance.

Arbus 25 Practically a Master Poster

Hello,
whats your test data?
because it works for 4 , 222 etc,.