DJSAN10 28 Posting Whiz in Training

int input(char s1[], char &ch, int &state, int pos)

Here &state means address of state, and you are passing value of state here :

input(s1,ch,state,pos);

There is no need to pass address of state since you are returning state.
If you want to pass by reference then you will have to pass address when you call a function ..ex . someFunction(&a) and in the definition you will catch it in a pointer like say,

void someFunction(int *p)
{
   //and you will access its value here using *p which means value at address contained in poiter p
}

See which one suits your needs, n modify your code accordingly.

Also next time when you post a code use code tags

DJSAN10 28 Posting Whiz in Training

cout << students.name << " " << students.age << "yrs" << endl;

Put this in a new loop from 0 to 4 again. What you have done will not print since i will be incremented to 5 and there is no element at 5th position in array.You will again have to loop through entire array from the beginning and print element one by one

DJSAN10 28 Posting Whiz in Training

Post your latest code along with error (if any) or output. We already know your expected output now. Post what you are getting

DJSAN10 28 Posting Whiz in Training

Here is a stack overflow thread that highlights on this issue
http://stackoverflow.com/questions/729692/why-should-files-end-with-a-newline

and there is 1 from here too.. :) :)
http://www.daniweb.com/software-development/c/threads/7957

DJSAN10 28 Posting Whiz in Training

int i should be outside struct definition. Still post what error you are getting

DJSAN10 28 Posting Whiz in Training

You would probably like to post it in the Game Development section or the moderator could just move it there

DJSAN10 28 Posting Whiz in Training

What I would like to suggest to you now is something you can call as "dry run".
You take a piece of paper and pencil, start from main , and work through the entire flow of your program. Like when a function is called go to that function, see the initial values of all variables, compute on paper how they are being modified and whether the modifications are correct. Move according to the flow how your program is going to take and check out all possibilities. You can try doing this first when you wake up tomorrow and are all up to code again :)

DJSAN10 28 Posting Whiz in Training

@Vastor Always!! C++ never should be a bad choice for anyone. :)

If you are interested in maths then if you go deeper you will realize programming is in some or the other way Maths.

Other computer fields where you yourself will use lot of mathematics is game programming or digital image processing. You can check some stuff about it on the internet maybe you will develop interest in it. It is always good to earn money doing things that you love to do.

And on your very first question, I would suggest just go through the summary of all chapters you had previously read. Some important author notes made in between, or if you have made your own notes besides. You can just go through them and continue where you left and always come back whenever you feel like you are stuck :)

DJSAN10 28 Posting Whiz in Training

To me your code seems ok logically. Just a small guess, are you sure you enter a newline in your text file at the end i.e. after 15. If not just give it a try. I am not sure this will work but can't think of anything else at this moment

DJSAN10 28 Posting Whiz in Training

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1

There you go. That IS your problem.

Follow the suggestion that cOrRuPtG3n3t!x just gave and I think you will be through. Your array is not being created as an array of 3 elements since you are attempting to create the array first and then setting its size parameter to 3.

And next time make sure you post you error/exception right from the beginning so it becomes much easier for us to help you out. :)

DJSAN10 28 Posting Whiz in Training

Read DJSAN10's post ... So that might be the problem, why not make the Bank constructor accept an int argument to assign a value to numAct for each instance

Exactly, I was about to suggest the same

DJSAN10 28 Posting Whiz in Training

Okay in your constructor for bank, there is a line

accounts = new Account[numAct];

and then you are doing

ccounts.setNumAct(numAct);

Thus when in your constructor , numAct is nothing but 0

DavidKroukamp commented: good eye +9
DJSAN10 28 Posting Whiz in Training

public int numAct = 0;

and

accounts = new Account[numAct];

..????

and where is your main function?

DJSAN10 28 Posting Whiz in Training

I did not understand your question.It is going in the if statement for the first time according to what output you are getting. I suppose your problem is something else.

done = true;

and

while(! done)

Assuming initially value of done was false, so !done evaluated to true and you entered while loop for the first time. But when you assign true to done, while will evaluate to false , and you will not go inside the loop at all.

I think you should change it to,

while(done)

All in all, I don't find a good use of while inside for in your case

DJSAN10 28 Posting Whiz in Training

1.Take number of rows as input from user
2.Loop until all rows are done
3.According to the pattern, number of elements in a row = row number itself. Loop for printing elements in 1 row. If the element number you are printing is odd ,print 1, if it is even print 0.

Start coding and post back if you have any further problems in your code.

DJSAN10 28 Posting Whiz in Training

Well there are many mistakes out there, lets go one by one.

In your first for loop you are simply taking the values. You need to put them somewhere. Since you want to put them in an array, that code should come within the for loop.

int number = input.nextInt();{
int array[] = new int [number];

Declare number and array before the for loop. Inside the for loop you will only have

number = input.nextInt();

and

array[counter] = number; // here you are assigning number to element of array

And then finally after the for loop is complete you write another loop (with corrections mentioned above to traverse through that array and concatenate it to output string)

DJSAN10 28 Posting Whiz in Training

for (int number, numbers) {

Why the opening brace here. You don't need that

DJSAN10 28 Posting Whiz in Training

for (int number, numbers)

Also , what is numbers here ..?? YOu need to use array

DJSAN10 28 Posting Whiz in Training

I think you are trying to do something like this :
for(declaration : expression)
{
//Statements
}

Note the colon, Its not a comma

DJSAN10 28 Posting Whiz in Training

for (int number, numbers)

This is wrong syntactically..What are you trying to achieve here?


EDIT : All three posted at the same time :) :)

DJSAN10 28 Posting Whiz in Training

Look here, specifically in the discussion of "bound imports". This is the only use I am aware of.

Hey thanks a lot for your reply .I' ll go through the link

DJSAN10 28 Posting Whiz in Training

Okay.. that is your problem. It reads newline as second input after you enter 'n' and thus enters default . Maybe you could check for getchar() != EOF

EDIT : deceptikon and I posted at the same time :P :D

DJSAN10 28 Posting Whiz in Training

input = getchar()

Might be causing the problem...!!!! ? Although i am not quite sure

DJSAN10 28 Posting Whiz in Training
DJSAN10 28 Posting Whiz in Training

Can some help me fix and improve the code.

If you are getting any errors or Exception..post them

DJSAN10 28 Posting Whiz in Training

I have an idea in mind. I want to create a Terminal (Windows Command Prompt) based completely in Java, capable of creating, compiling, editing, etc for Java files. I would like this to also resemble the look of Terminal/Command Prompt. Being the black background, and the text start like below.

Basically, you want to create a command based IDE. I don't see any practical use of it today since people will always prefer to use a GUI based IDE. But if you are doing it for your own practice then its okay :) :)

DJSAN10 28 Posting Whiz in Training

int LinearSearchArray ( const int list[], int numEless, int value)

{ //<<--------this is where I get my error
int index=0;
int position= -1;
bool found = false;


while(index < numEless &&!found)
{
found = true;
position = index;
}

index ++
}
return position
}

There is no semicolon after last two lines
index++ and return position

Eagletalon commented: Well Spotted +3
DJSAN10 28 Posting Whiz in Training

Okay, honestly speaking I don't know the exact contents of time stamp.

And what are you considering a header?

The header I am talking about is the one attached by a linker which is removed when a program becomes a process (i.e. brought into memory). Since linkers are operating system dependent their headers differ from OS to OS. But there are a few common things which every linker adds to the header of a (can say COFF) file. One such thing being Time stamp. I want to know what is this time stamp exactly and what difference would it make if this primary header of a file does not contain any time stamp as such

DJSAN10 28 Posting Whiz in Training

It means that someone could mess up with any machine then. i would run my program on someone else's computer and create trouble for him. But this should not happen , right?? Does system take any care for this ?

DJSAN10 28 Posting Whiz in Training

Okay, so I don't know much about this and maybe that is why the doubt. I am pretty sure there must be some precaution if some one tries to create (can say a virus) like this :

while(1)
{
   /* creat system call. to create files continuously. Not difficult to give different file name each time */
}

Inode list doesn't get exhausted here right? But what is done to avoid this ? Or does it mean that we cannot create anymore files?

DJSAN10 28 Posting Whiz in Training

Any file's primary header contains some things which are common to all operating system like entry point function, time stamp etc and then other things. What is the purpose of keeping this time stamp in the header.

Thanks

DJSAN10 28 Posting Whiz in Training

So what you can do is, till you reach that max possible value, increment(here multiply) accordingly, after that , decrement(here divide) accordingly.

Also note the number of elements in each row. They follow a pattern too. Try guessing that on your own . If you don't get it we will help you. You can then use that value as condition in your loop. Enjoy coding :)

DJSAN10 28 Posting Whiz in Training

You can think of it like this : in terms of row no. and max possible value i.e. (We consider row 1 as row 0 )
row 0 , max possible 1
row 1 , max possible 2
row 2 , max possible 4
row 3 , max possible 8
row 4 , max possible 16
row 5 , max possible 32
row 6 , max possible 64
row 7 , max possible 128

Now , can you make out the pattern..????

DJSAN10 28 Posting Whiz in Training

for (k = 1; k < i*2; )

i's maximum value will be 8 . Hence condition k < i * 2, means k can at the max be 16 . It will never go ahead of 16.

DJSAN10 28 Posting Whiz in Training

public abstract class Student extends Person {
protected Course[] courses;

and

public class Course {

private Student[] students;

I think this MIGHT be the reason. If you first create student object, course will be empty and if you first create course object student there will be no students for initialization. I am not sure , because you have also provided constructors without them . Maybe if you could post your main method where you have created objects and called functions on them.

And you can always go with what NormR1 just suggested

DJSAN10 28 Posting Whiz in Training

replace1("&tablehostvars",StrFinRow);

Is that a different function ?

It will be better if you post the entire code.

DJSAN10 28 Posting Whiz in Training

printf("Please select a finishing position for a figure for instance E4\n");
scanf("%c %d",&c1,&y0);
printf("%c\n",c1);

Again you ended up putting a space between your format specifiers in scanf.

DJSAN10 28 Posting Whiz in Training

printf("Please select a finishing position for a figure for instance E4\n");
scanf("%c %d",&c1,&y0);
printf("%c\n",c1);

AGAIN you ended up giving a space here.

DJSAN10 28 Posting Whiz in Training

But what about the Mac?
Maybe, it's silly to ask this, but can I use DirectX on Mac?
Now, which is better in those two?

Apple ships OpenGL as a standard feature of the Mac OS (OS9 and Mac OS X). You can search for it on the net.

DJSAN10 28 Posting Whiz in Training

Well in char_to_int() , try doing this..

x = c - 'A'

What you have done should not be a problem IMO, but its time for some trial and error

Actually , even output of your first scanf is wrong it should be 4 and not -4

DJSAN10 28 Posting Whiz in Training

Okay paste what does it print now. All values. For both scanfs.

DJSAN10 28 Posting Whiz in Training

I didn't mean you separate the scanfs. Anyways did you enter your input as told. Give a number, press enter, give a number, press enter, and so on

DJSAN10 28 Posting Whiz in Training

Maybe you would like to post the code where you have called replace function.

DJSAN10 28 Posting Whiz in Training

Ok so here is where you are stuck. How will scanf identify E and 2 are different characters when you enter E2. The problem is in the way you are giving your input. You should :
E<Press Enter>
2<Press Enter>

Similarly,
E<Press Enter>
4<Press Enter>

DJSAN10 28 Posting Whiz in Training

1. Write a c++ program that generates the following series: 0 -1 4 -9 16 -25 36 -49 64 -81 100

You simply need to print the squares of a number .
You can use square_of_num = num * num. Also every odd number has negative sign. It means if square_of_num < 0 multiply it with -1 .

2. write a program that generates the fibonacci series: 1 1 2 3 5 8 13 up to 50th term.

Loop till 50th term. Inside loop print your fibonacci number. Your logic will be that next number is equal to sum of previous two numbers . So to start with , you will have to take 2 numbers both initialized to 1.

Atleast start coding. Doesn't matter if it is wrong. We are here to help. But you need to start coding on your own first :)

DJSAN10 28 Posting Whiz in Training

Okay, LISTEN.

printf("Please select a finishing position for a figure for instance E,4\n");

Tell me what input you are giving after this statement. Are you giving it as E4 or E,4 or E 4. i want to know that

DJSAN10 28 Posting Whiz in Training

Next (although not related to your problem but what you have done is bad programming) : For setup_board() , use for loop ,don't assign values individually

DJSAN10 28 Posting Whiz in Training

I think you are giving the wrong input here. E,4 or E4. Post EXACTLY what input you have given and the exact output that you have got. Also ,no space here : use

scanf("%c%d",&c,&y);
DJSAN10 28 Posting Whiz in Training

scanf("%c,%d",&c,&y);

There should be No comma between %c and %d!!!!

DJSAN10 28 Posting Whiz in Training

In starting position im getting a proper values
E2
c->E
x->4
y->2
but in finishing position i'm getting
c1->4
x->2
y->-55
why??

What did you input as finishing position.