Arbus 25 Practically a Master Poster

In the line 1 declare x as int instead of char. It would be better that way.

Arbus 25 Practically a Master Poster
getchar();
scanf("%c",&choice1);

When you type something for getchar and press enter, the linefeed '\n' goes into the choice1. That is scanf will not prompt the user to enter a character. Instead it will take the last key you pressed for getchar()

Arbus 25 Practically a Master Poster

It's simple. Just break them into segments.
hour < 10 ? "0" : " "
The hour <10 part tells that if value of hour is less than 10 then 0 will be displayed, if hour is not less than 10 then it displays nothing.
If the condition is satisfied then the expression following ? is done if the condition is not satisfied then the expression after : is done.

Use code tags

Arbus 25 Practically a Master Poster

Answers to few questions...
6)#pragma
7)This is one way :
private members of a class can be accessed by the functions pertaining to that class.
3)http://www.exforsys.com/tutorials/c-plus-plus/polymorphism-an-introduction.html

Is google-ing so tough?

Arbus 25 Practically a Master Poster

You can download camstudio from here It records whatever that comes onto the sceen.

Arbus 25 Practically a Master Poster

Correction to the code posted by sodabread. There should be ; in line 8 and line 15.

? product is not a data type right? But why was it placed there? help please

product inventory[10];

It's a way to declare objects for a structure.

struct product
{
    string brand;
    int stock;
    int sold;
    float price;
    // Other items that pertain to a product
}inventory [10];// Another way to declare objects for a structure.
Sodabread commented: Thanks for covering me. Don't check much on weekends =) +7
Arbus 25 Practically a Master Poster

In the previous pattern the letters were increasing and now it should decrease for the next pattern. Just decrement values instead of incrementing. The for loops will look like this.

for(i = strlen(wrd)-1;i>=0;i--)
{ for( j=0;j<=i;j++)
  { 
   //complete this
   .
   .
  }
}
Arbus 25 Practically a Master Poster

Arrays should be given constant size while declaration. See this

Arbus 25 Practically a Master Poster

int ctrLet;

if(ctrLet[ctr] > 0)
cout << ctrLet[ctr] << " " << alphaLet[ctr] << endl;

ctrlet is an integer and it is not declared as an array.

Arbus 25 Practically a Master Poster

Hint: Use two for loops separately for the increasing pattern and two for decreasing pattern.

Arbus 25 Practically a Master Poster

Make sure that the icons are not hidden. If nothing works then atlast go for system restore.

Arbus 25 Practically a Master Poster

Hello niths,
Words are separated by spaces. Find where the first space occur. The characters preceding the space will give you the word.
Since you want the last word of the string look for the space from the end.

>>abellazm
You are fast in typing.

Arbus 25 Practically a Master Poster

Can you post the errors ?

BITMAP* Switch;

switch is a keyword. Variables in the name of keywords are not allowed.

Arbus 25 Practically a Master Poster

It gives those errors because you didn't change the prototype for sort_surname()
The prototype should be

void sort_surname(char**);/* not that the parameter Acc[] is not given*/
Arbus 25 Practically a Master Poster

I guess you meant
C Syntax (Toggle Plain Text)
char *account_array;

Yeah, sorry that's due to my poor typing.

Arbus 25 Practically a Master Poster

In your code the declaration of the pointer account_array is fine.

char (account_array[size];

Your function declaration is also fine.

void sort_surname(char *account_array[])

The mistake lies in the function calling in line 51.

sort_surname(number, *account_array);

Here you have passed structure, but in your function you didn't have any parameter to get structure.
So it should have been

sort_surname(account_array);
Arbus 25 Practically a Master Poster

Give some object in the declaration.
For example..

sort_surname(ACC obj[],char *account_aray);

But i see that you are not using the any object in the function sort_surname(). So remove the parameter in the declaration and don't pass any structures in line 51.

case 2:
      sort_surname(account_array);//not the number parameter
      break;

In the function ..

void sort_surname(char *account_array[]);

Hope this helps.

Arbus 25 Practically a Master Poster

In line 97 it seems that you have removed the parameter for structure, but you are passing a structure in the line 51. Check that out.

Arbus 25 Practically a Master Poster

can you post the modified code?

Arbus 25 Practically a Master Poster

It's giving that error because *account_array is not declared in main(). Keep in mind that the parameter is *account_array[]. So you should declare it appropriately.

Arbus 25 Practically a Master Poster

Yes, in the switch case function an array is not passed as a parameter sort_surname ( number, /* *string */ );
And in the function definition of sort_surname object has not been declared. I wonder how come you haven't got any errors?

void sort_surname(ACC,char *account_array[])//here the object should have been declared
drongo commented: THANKS +0
Arbus 25 Practically a Master Poster

Hello drongo,
In your function calling you didn't mention all the parameters. You didn't give the char* parameter.

Arbus 25 Practically a Master Poster

Hello markee,
ASCII value of character 0 is 48 and '1' is 49. When you subtract these ASCII values you will get the required value 1.
For example,

char a;
int b;
b=int(a)-'0';
Arbus 25 Practically a Master Poster

Hello ThrasherK,
I hope coursename is a string. In the line 10 you have declared coursename as character variable. Declare it as a pointer or as a character array.

Arbus 25 Practically a Master Poster

yes it repeats adding the number to itself(to variable product)several times.

Arbus 25 Practically a Master Poster

Sorry it should have been subtracted with '0'.

char a[5]="2358";
int a;
a = ((a[0]-'0')*1000))+((a[1]-'0')* 100))+((a[2]-'0')*10)+(a[3]-'0');
Arbus 25 Practically a Master Poster

Hello itslucky,
You can do as gerard4143 said or you an also do this.
Declare a character array. The values in the character array can be converted to integers by doing this.

char a[5]="2358";
int a;
a = ((a[0]-'\0')*1000))+((a[1]-'\0')* 100))+((a[2]-'\0')*10)+(a[3]-'\0');

Variable 'a' will have the integer 2358.

Arbus 25 Practically a Master Poster

Hello francis25,
consider a set {2,2,2,2,2,2,2}, to find the sum of all elements in the set, you would count the number of 2's and multiply it with 2. You can also add all the 2's instead of multiplying and that's what is done in the code you posted. Variable i is used in the for loop so that the element is added up to the number of times it occurs.

Arbus 25 Practically a Master Poster

You gave i<=N in the for loop. If we take 6 then 1,2,3,6 are all added with sum rather than 1,2,3. That's why you get the wrong output.

Arbus 25 Practically a Master Poster

Hello salty11,
There is a semicolon after for loop. You have terminated the loop.

for(i=1; i<=N; i++);
Arbus 25 Practically a Master Poster

Hello xeno86,
Use fflush(stdin) before scanf for again as charley bones said. The loop doesn't work because as you press enter('\n') the '\n' is copied onto the variable again. You can also use flushall() before the scanf() for again.

Arbus 25 Practically a Master Poster

Hello tamyln,
The problem lies with your calcactualamount funciton. You gave return amountp in a while loop. It's wrong. You should give return statement outside the loops. A function can return only one float value.

Use code tags.

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 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

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

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

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

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
}