• Status: Solved
  • Priority: Low
  • Security: Public
  • Views: 65
  • Last Modified:

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

0
Ewe kean tan
Asked:
Ewe kean tan
1 Solution
 
sarabandeCommented:
#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
0
 
Ewe kean tanJunior C++Author Commented:
i using old version quincy 2005 . This should include h.extension . the problem is output cant display
0
 
sarabandeCommented:
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
0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

 
sarabandeCommented:
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
0
 
sarabandeCommented:
if your platform is windows you can get visual studio 2017 community for free.

Sara
1
 
RaminTechnical AdvisorCommented:
Try This:
#include <stdio.h>
0
 
sarabandeCommented:
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
1
 
evilrixSenior Software Engineer (Avast)Commented:
Well, I've compiled your code (after fixing iostream.h, as suggested by Sara) and I get the following output...


Success      #stdin #stdout 0s 15240KB
Linked list is:
NULL
The minimum element in linked list :
2147483647

https://ideone.com/iOqk5b to view the code and output.

So, with that in mind, what - exactly - is your issue? What is the expected output?
2
 
Ewe kean tanJunior C++Author Commented:
my expected output was find the smallest element in linked list while get the user input  . btw u code is work well .
0
 
Ewe kean tanJunior C++Author Commented:
i will try sara suggest  visual studio 2017  ...Thank you sara
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now