zeroliken 79 Nearly a Posting Virtuoso

Maybe instead of using continue why not change the value of ctr back to 0 whenever the user inputs 0?

zeroliken 79 Nearly a Posting Virtuoso

So whats the problem?... If I understand what you just said that part of the code is doing what its suppose to do :?:

zeroliken 79 Nearly a Posting Virtuoso

continue; causes a while or for loop to begin again at the top of the loop.

Do you need to decrement the value of ctr to have another value?

zeroliken 79 Nearly a Posting Virtuoso

scanf("%c",&ans);

at line 27 use %s instead of %c

D33wakar commented: I don't think thats gonna help instead complicates the problem. -1
zeroliken 79 Nearly a Posting Virtuoso

could you post what the error says?

zeroliken 79 Nearly a Posting Virtuoso

can you at least tell me if I should use a while or for loop? It can go either way

Either loop will be fine as long as you use them correctly

for (int i = 0; i < grades.length;i++)

I think you should use (count) as a counter to read parts of the array that has a value instead of reading the whole elements of the array
of course you need to increment the value of count in the loop that asks the user for the numbers to have a definite number of elements to read

IMHO NormR1 has said and explained everything on how you should tackle on making the loop for the string... showing the code would be spoonfeading already

zeroliken 79 Nearly a Posting Virtuoso

The integer part of fgets is used for the maximum number of characters to be read (including the final null-character). Usually, the length of the array passed as str is used.

zeroliken 79 Nearly a Posting Virtuoso

try using fscanf when reading a file, you can use google if your not familiar on using fscanf

zeroliken 79 Nearly a Posting Virtuoso

I have done a thing that i have initialized an array of [100][100] and this has made my work a lot easier. Still the problem i am facing is that how to evaluate the standing of students with their id's in the descending order e.g student id 07 has got topped the exam and then how to give the feedback on the most frequently missed question.

I suggest you make another array that has the same size as the number of questions, here you will store the number of times a student makes a mistake on a particular number

how to evaluate the standing of students with their id's in the descending order

Either add one more space to the answers array of each student or make a separate array where you will store the total score of each student so you can compare them

zeroliken 79 Nearly a Posting Virtuoso

Thank you everybody.
I tried your suggesstions and the error has gone away and program has been compiled successfully. but when I execute my program, after entering the username, It returns Invalid Username message.

Please check the following code:

import java.util.Scanner;
public class Login {
    public static void main (String[] args) {
             String user = "admin";
             int pass = 123;
             int p;
             String u;
    	Scanner s=new Scanner(System.in);
            System.out.println ("Enter Username:");
    	 u=s.nextLine();
    	 if (u == user) {
    	  	System.out.println ("Enter Password:");
    	 	p=s.nextInt();
    	    if (p == pass) {
    	        System.out.println (" ");
    	        System.out.println ("Welcome to admin area. Please choose an option");
    	        System.out.println (" ");
                     }
                 } else {
    	        System.out.println ("Incorrect Password");
         	    }
         } else {
    	        System.out.println ("Invalid User");
         }
    }

}

check JamesCherrill's post above

zeroliken 79 Nearly a Posting Virtuoso

If you don't pass on the first "if" statement then "p" will have no value making it uninitialized

zeroliken 79 Nearly a Posting Virtuoso

Hello fanniecarnes , glad to communicate with you here :) , do you use Python ?

You could check their profiles to know where they like to post

zeroliken 79 Nearly a Posting Virtuoso

Try to check / test first / (temporarily remove) each statement in the function to pinpoint which line causes the program to give a segmentation fault

either that or post the complete program

zeroliken 79 Nearly a Posting Virtuoso

the problem i am facing is that i dont know how to match each students answers with the correct answer.this has to be done with dynamic arrays. Help me in this:

Compare each of the values using a loop

As for all the students

You could initialize the student and their corresponding answers using a multidimensional array... it makes it a lot easier

a = (int **)malloc(sizeof(int *) * row); //where row is the number of students
                for(x=0; x<row; x++)/*for row 1 to last number of student*/
                        *(a+x)=(int *)malloc(sizeof(int) * col);
/*create another set of arrays for their answers depending on the number of students*/
zeroliken 79 Nearly a Posting Virtuoso

Oh, firstly, im sorry if i did not write clearly coz i dont speak English!
In your code, the largest number depends on the memory and the maximum number of int type!
And about "exist", as i know, fibo sequence start with i = 0, so i think fibo(-1) = NULL

There should be an else if statement that returns 0 if "i=0" to avoid fibo(-1) and replace "i<=1" to "i==1"

If you want to have the next Fibonacci number then just add 1 to N(the value you pass)

zeroliken 79 Nearly a Posting Virtuoso

exp.txt is created which is empty.

Since "ch" has no value you don't write anything in the file

zeroliken 79 Nearly a Posting Virtuoso
for ( int i=0;i<=size;i++){
if(array[i]==array[i].length-1)
    System.out.print("plindrom ");
else
    System.out.print("not plindrom ");

try to check the values of array[i] and array[i].length-1 at the loop to know what your program is doing

zeroliken 79 Nearly a Posting Virtuoso

He's right the longer the code the harder it is to pinpoint the problem
So for now I'll post a simple tutorial relating your problem
platform tutorial

zeroliken 79 Nearly a Posting Virtuoso

Are you still having problems on the collision?
Maybe this tutorial ca help ya
collision tutorial

zeroliken 79 Nearly a Posting Virtuoso

In my code I break the loop if the operations get bigger than the input so as not to put stress on the cp and since its not anymore necessary to continue the operation since its already not perfect square

else if(x>input){
        break;
    }

PS. I made a program that checks if the input is a magic number not create one ;)

zeroliken 79 Nearly a Posting Virtuoso

Ive made my own version of your assign I'll post what it should do to solve if the number is a magic square
note: I won't post my whole code and the one I'm posting should only serve as a guide to simplify your work

boolean one = false;
boolean two = false;
while(a!=input){
    a++;
    x = (int) Math.pow(a, 2);
    if(x==input) one = true;	
    else if(x>input){ 
        break;
    } 
}
x=0;a=0;
while(a!=input){
    a++;
    x+=a;
    if(x==input) two = true;	
    else if(x>input){
        break;
    }
if(two == true && one == true) System.out.println(input + " is a magic number");
}
zeroliken 79 Nearly a Posting Virtuoso

Start small like trying to get if the input is a perfect square before the others

zeroliken 79 Nearly a Posting Virtuoso

for me, it looks like total never matches x.

and maybe that's why 'a' never iterates which makes it loops forever

zeroliken 79 Nearly a Posting Virtuoso

Try to print out the value of a,x,b and total every time their value changes to see what happens to them in your loops

It will be easier to pinpoint the problem

zeroliken 79 Nearly a Posting Virtuoso

for(int useless = 5; a < input; b++)

if the value of a remains the same then it will loop forever as the condition a can never be greater than or equal to input

zeroliken 79 Nearly a Posting Virtuoso

for(double x = Math.pow(b, 2)..

that's because as it loops it keeps replacing the value of x from
double x = Math.pow(b, 2)
maybe remove it from the loop ;)

you should have posted this in the java forum cause your problem is using a specific language(java) directly...maybe a mod will move this anytime

zeroliken 79 Nearly a Posting Virtuoso

Thank you for your useful input :) You are correct, I meant
while(grade.equals("A") || grade.equals("B") || ...

but that gave me an error message, I don't really think || will work for Strings.

huh really... || in a while statement means it will continue to run as long as at least one of the conditions will suffice

I think it should work regardless of the data type

P.S.JamesCherrill Did a better way of showing how the while loop should continue to run
rather than my lazy while(true) :)

zeroliken 79 Nearly a Posting Virtuoso
while(grade.equals("A" + "B" + "C" + "D" + "F")){ //try while(true)
grade = in.next(); //include this in the loop
joankim commented: thank you mate :) +0
zeroliken 79 Nearly a Posting Virtuoso

Since there's no limit in grades I suggest using a while loop instead of a for loop then stop the loop when a non-grade character is input

zeroliken 79 Nearly a Posting Virtuoso

Print out the values of the array containing the string using a loop
the number of letters that would be shown would depend on the current value of the counter

zeroliken 79 Nearly a Posting Virtuoso

If you have no more questions mark this thread as solved otherwise just ask

zeroliken 79 Nearly a Posting Virtuoso

create a Ticket object so you can invoke the method on it
ex.

// Create two different 
// Bicycle objects from a Bicycle class
Bicycle bike1 = new Bicycle();
Bicycle bike2 = new Bicycle();

// Invoke methods on 
// those objects
bike1.changeCadence(50);
bike2.changeCadence(50);
zeroliken 79 Nearly a Posting Virtuoso

could you post the whole error message

zeroliken 79 Nearly a Posting Virtuoso

use the value of the array instead of n

zeroliken 79 Nearly a Posting Virtuoso

Well I didn't mention Forger's since i think it's exclusive for windows
(maybe GTK+)
but my main point is it would be better if you can make the the basic purposes of the program work on a compiler before trying to make it run on a window

zeroliken 79 Nearly a Posting Virtuoso

You must DECLARE the function before using it. In this case you only DEFINED it after you used it. The compiler won't let you use it unless you at least DEFINE it before you use it. Search more and learn about defining and declaring functions and variables. In your case is simple , after :

using namespace std;

put

void testFunction();

....... rest of code .....

you mean a function prototype like in phorce's post

zeroliken 79 Nearly a Posting Virtuoso

Also don't forget to free the memory after use

for(j=0;j<noe;j++){
              free(p[i]);
        }
	free(p);
dij_0983 commented: Was searching the forum and found this,thanks +1
zeroliken 79 Nearly a Posting Virtuoso

Maybe reading this can help
Things to avoid in c/c++ - gets()

zeroliken 79 Nearly a Posting Virtuoso

I have to write persian (farsi) characters to a text file, but after writin when I open the file ,it's contents are unreadeable in persian and ther is some special characters
pleaseeeeeeeeeeeeeeeeeeeeeeee help :-(

Don't hijack another person's thread start your own

zeroliken 79 Nearly a Posting Virtuoso
gets(p[j]); //use scanf
puts(p[j]); //use printf
zeroliken 79 Nearly a Posting Virtuoso
#include<iostrem>    //you mean #include<iostream> right?

you forgot the a

zeroliken 79 Nearly a Posting Virtuoso

try to trace the program on the loop containing k as the counter
the value of check must be still equal to true cause after that loop you break the statement before that and then you break the statement before that...until you break the while loop

zeroliken 79 Nearly a Posting Virtuoso

Kindly send the code. I need the code to transfer bulk of files from clinet to server. if you have the code means ,please share it with me. Thanks in advance

1.your hijacking a thread (start your own)
2.the thread your hijacking/reviving is from 2 years ago (necroposting)
3.we don't "give" codes as we're not a coding service we only help those who show effort on their side

zeroliken 79 Nearly a Posting Virtuoso

good for you :)

zeroliken 79 Nearly a Posting Virtuoso

till the last iteration of "i" (the outer loop counter)
in my example it's 6

Isn't it your job to manipulate your own code?

zeroliken 79 Nearly a Posting Virtuoso

Tried making another if statement, but same output...

Of course it will still do that cause

The problem here is that you use the last value of largest2 instead of its next value

same can be applied on another if statement

zeroliken 79 Nearly a Posting Virtuoso

i dont get it ????

else if(i == 4){
//another loop which prints a different number of  * 
}
else if(i == 5){
//another loop which prints a different number of  * 
}
//do this until all values of i is covered
zeroliken 79 Nearly a Posting Virtuoso

&& largest2 != largest

The problem here is that you use the last value of largest2 instead of its next value

zeroliken 79 Nearly a Posting Virtuoso

it doesnt print anything it prints errror

post those errors here

zeroliken 79 Nearly a Posting Virtuoso

Tried that, but I think it's an issue of the integer largest2 being declared as 0 in the beginning. So basically, 0 is not equal to 12, and therefore it just prints out 12 for largest2.

I don't think your 2nd loop works like that