Link to home
Start Free TrialLog in
Avatar of Ewe kean tan
Ewe kean tan

asked on

my output cant display

#include <iostream.h>
#include <bits/stdc++.h>

using namespace std;
      
	  
	   struct Node
	   {
	       int data;
		   struct Node* next;
		   };
		   
		   
		   int small(struct Node* head)
		   {
		   
		   int min = INT_MAX;
		   
		   
		   while (head != NULL)
		   {
		   
		      if ( min > head->data)
			       min = head->data;
				   
				   head = head->next;
				   }
				   return min;
				   }
				   
				   
				   
				   void push (struct Node ** head ,int data)
				   {
				   	struct Node * newNode ;
					
					newNode->data=data;
					
					newNode->next = (*head);
					(*head) = newNode;
					}
					
				   
				   void display(struct Node* head)
				   {
				    while ( head != NULL ) 
					{
					   printf("%d -> ", head->data);
                          head = head->next;
					
					}
					cout << "NULL" << endl;
					}
				   
			int main()
			{
			   int x;
			  struct Node* head = NULL;
			  
			  
			   push(&head,5);
			   push(&head,10);
			   push(&head,19);
			   
			   cout << "Linked list is:"<<endl;
			   
			   display(head);
			   cout <<"The minimum element in linked list :"<<endl;
			   cout << small(head) <<endl;
			   
			   
			   return 0;
			   }

Open in new window

Avatar of sarabande
sarabande
Flag of Luxembourg image

#include <iostream.h>

Open in new window


this header file is deprecated since 19 years.

use

#include <iostream>  // no .h extension

Open in new window


to get the classes from C++ standard (STL) in namespace std.

Sara
Avatar of Ewe kean tan
Ewe kean tan

ASKER

i using old version quincy 2005 . This should include h.extension . the problem is output cant display
c++ standard is from 1998 and you were using statements like

using namespace std;

Open in new window


which only would compile if the compiler HAS a standard template libary (STL).

what happens if you were using the right include statement?

Sara
note, an 11 years old compiler doesn't give any advantage, even if you have old code which doesn't compile with newer compilers.

all the errors you get easily could be corrected granted that your coding has at least basic quality.

Sara
if your platform is windows you can get visual studio 2017 community for free.

Sara
Try This:
#include <stdio.h>
don't think you should use stdio.h in c++

it is  a c header for console output. some of the functions like printf belong to the most dangerous code functions as they are vulnerable to be hacked by malware.

if you are on unix you should use gcc and eclipse.

i found the following regarding quincy 2005:

Because of it's simple interface, Quincy is ideal for learning C or C++ ... Quincy 2005 makes it easy to use the MinGW C/C++ compiler, and the GDB debugger.

the MINGW compiler has actual compilers which are compliant wit newer c++ standards (like c++11) . the quincy is only an IDE and the compiler could be updated with newer versions.

Sara
ASKER CERTIFIED SOLUTION
Avatar of evilrix
evilrix
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
my expected output was find the smallest element in linked list while get the user input  . btw u code is work well .
i will try sara suggest  visual studio 2017  ...Thank you sara