Click here to Skip to main content
15,667,864 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Write a C program to display the even nodes in a linked list.

What I have tried:

I have written the program and compiled it.The program is showing no errors.But I am not getting the desired result.Since my input is given as 1->3->2->6->7->10; I should get the output as 2->6->10...but am getting the output as 1->3->2->6.Can someone please help me??
Updated 25-Jul-17 21:32pm
Member 13329129 26-Jul-17 2:48am    
How do you want me to improve the question..?I have already stated it.
CPallini 26-Jul-17 3:13am    
In order to get help you should post your code.

We can't help you with this - it needs your data, and to be looking at what is happening while the code is running on that data. And we don't have your data, we don't have your whole app - and we don't know how to use it if we did!

So, its going to be up to you.
Put a breakpoint on the first line in the function, and run your code through the debugger. Then look at your code, and at your data and work out what should happen manually. Then single step each line checking that what you expected to happen is exactly what did. When it isn't, that's when you have a problem, and you can back-track (or run it again and look more closely) to find out why.

Sorry, but we can't do that for you - time for you to learn a new (and very, very useful) skill: debugging!
Share this answer
I have written the program and compiled it.The program is showing no errors.

This means that your code respects the syntax of the language, it doesn't mean that the code does what is expected.
"the cat flies high in the sky" is a sentence that respect Ebglish syntax, but means nothing.
But I am not getting the desired result.

That is typical from a buggy code. try to show code for real help, or learn debugger.
There is a tool that allow you to see what your code is doing, its name is debugger. It is also a great learning tool because it show you reality and you can see which expectation match reality.
When you don't understand what your code is doing or why it does what it does, the answer is debugger.
Use the debugger to see what your code is doing. Just set a breakpoint and see your code performing, the debugger allow you to execute lines 1 by 1 and to inspect variables as it execute.

Debugger - Wikipedia, the free encyclopedia[^]

Mastering Debugging in Visual Studio 2010 - A Beginner's Guide[^]
Basic Debugging with Visual Studio 2010 - YouTube[^]
The debugger is here to show you what your code is doing and your task is to compare with what it should do.
There is no magic in the debugger, it don't find bugs, it just help you to. When the code don't do what is expected, you are close to a bug.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900