How come you find out if a linked-list is a cycle or not?


No Answer is Posted For this Question
Be the First to Post Answer

Post New Answer

More C++ General Interview Questions

how can i access a direct (absolute, not the offset) memory address? here is what i tried: wrote a program that ask's for an address from the user, creates a FAR pointer to that adress and shows it. then the user can increment/decrement the value in that address by pressing p(inc+) and m(dec-). NOW, i compiled that program and opened it twice (in 2 different windows) and gave twice the same address to it. now look what happen - if i change the value in one "window" of the program, it DOES NOT change in the other! even if they point to the same address in the memory! here is the code snippet: //------------------------------------------------------ #include <stdio.h> //INCLUDE EVERY KNOWN HEADER FILE #include <conio.h> //FOR ANY CASE... #include <iostream.h> #include <dos.h> #include <process.h> main() { int far *ptr; //FAR POINTER!!! long address; char key=0; //A KEY FROM THE KEYBOARD int temp=0; clrscr(); cout<<"Enter Address:"; cin>>hex>>address; //GETS THE ADDRESS clrscr(); (long)ptr=address; temp=*ptr; //PUTS THE ADDRESS IN THE PTR cout<<"["<<hex<<(unsigned long)ptr<<"]="<<*ptr<<" = "<< (char)(*ptr); //SHOWS: [address]=value=ASCII symbol. while (key!=27) //WHILE YOU DONT PRESS ESC. { while(!kbhit()) //WHILE KEY IS NOT PRESSED { if (temp!=*ptr) { temp=*ptr; clrscr(); cout<<"["<<hex<< (unsigned long)ptr<<"]="<<*ptr<<" = "<<(char)(*ptr); }; //IF THE VALUE HAS CHANGED, CLEAR THE SCREEN AND SHOW //AGAIN if (key=='p') {key=0; (*ptr)++; } //INCREMENT VALUE if (key=='m') {key=0; (*ptr)--; } //DEC. VALUE }; key=getch(); //IF A KEY IS PRESSED, READ IT FROM THE //KEYBOARD }; return 0; //IF ESC WAS THE KEY, EXIT THE PROGRAM } //---------------------------------------------------------

0 Answers  


Explain the difference between new() and malloc() in c++?

0 Answers  


Write a short code using c++ to print out all odd number from 1 to 100 using a for loop

0 Answers  


Can you use the function fprintf() to display the output on the screen?

0 Answers  


What are the different operators in C++?

3 Answers   HP,






What are the advantages of using a pointer? Define the operators that can be used with a pointer.

0 Answers  


What are function prototypes?

0 Answers  


i have given a project to create examination seating plan system in c++. so can anyone send me the answer of this question quickly??????

1 Answers  


What are friend functions in C++?

0 Answers   BlackRock,


Why main function is special in c++?

0 Answers  


What is pointer to array in c++?

0 Answers  


What is the best c++ book for beginners?

0 Answers  


Categories