answersLogoWhite

0


Best Answer

This program works only on Microsoft compiler, people who are using another compilers will have to modify pointer initialization to

double vfirstNumber = 0.0;

double* firstNumber = &vfirstVariable;

...

double vsecondNumber = 0.0;

double* secondNumber = &vsecondNumber;

Or whatever you find is better.

#include <iostream>

using std::cin;

using std::cout;

using std::endl;

int main()

{

double* firstNumber = NULL;

cout << endl << "Enter first number: ";

cin >> *firstNumber;

double* secondNumber = NULL;

cout << endl << "Enter second number: ";

cin >> *secondNumber;

if (*firstNumber > *secondNumber)

{

cout << endl << *firstNumber << " > " << *secondNumber << endl;

}

else if (*firstNumber < *secondNumber)

{

cout << endl << *firstNumber << " < " << *secondNumber << endl;

}

else

{

cout << endl << *firstNumber << " = " << *secondNumber << endl;

}

system("PAUSE");

return 0;

}

User Avatar

Wiki User

12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Write a program to sort two numbers using pointers?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How to write a C program to find largest 2 numbers using pointers?

program to find maximum of two numbers using pointers


How do you write c program to perform sum of elements of matrix using pointers with functions?

i cant write


What will be the program to arrange numbers stored in array in ascending order using pointers?

sorry


Write a c program to copy two strings using pointers?

nahi malum


How do you write an assembly language program to find the sum of n numbers using array?

write an assembly language program to find sum of N numbers


How do you write a C program to copy to strings using pointers?

mystrcpy (char* dest, char* src) { while ((*dest++ = *src++) != '\0); }


How do you write a program to read set of numbers using by an array and display the ascending order of the given input numbers?

To write a C++ program to display the student details using class and array of object.


How do you find the biggest of n numbers using pointers in C?

yes


Write a program to find the product of two numbers using Halving and Doubling method?

i need this answer


Write a program large number and small number among n numbers by using If statement?

12


How do you run graphics program in C?

pro c language to implement linear search using pointers


Write a C program for sum of n numbers using pointers?

void main() { int n=0,i,*p; clrscr(); printf("enter the value of n"); scanf("%d",&amp;n); p=&amp;n; for(i=0;i&lt;=n;i++) { *p=*p+i; } printf("value of the sum is %d",*p); getch(); }