Can anybody help my with this C++ assignment???

Write a program that can sort integers, decimals, and characters from ascending and descending orders.

The program has to use the following C++ features:
- Take input from user
- Use different data types
- Use if statement
- Use while or for loops
- Use arrays
- Define and call functions
- Pass array or pointers to function
- Use function overloading
- Present output to the screen



What's the problem?
here is what I have so far



#include <iostream>
using namespace std;
int main()
{

int array [3], t;
for (int x=0; x<3; x++)
float f1, f2;
char c1, c2;
{

printf("(1) Sort in ascending order.");
cout << "Enter integer number " << x+1 << " : ";
cin>> array[x];
cout << "enter two decimals: \n";
cin >> f1 >> f2;
cout << "enter two characters:";
cin >> c1 >> c2;

}
for (int i=0; i<3; i++)
{
for (int y=0; y<2; y++)
{
if(array[i]<array[y])
{
t=array[i];
array[i]=array[y];
array[y]=t;
}
}
}
cout << endl;


cout << "The integers in ascending order are:";
for (int x=0; x<3; x++)
cout << " " << array[x];
cout << "the decimals in ascending order are : " << f1 % f2 << endl;
c1 = c1 + 3;
cout << "the characters in ascending oder are " << c1 << endl;
c2 = c2 -6;
cout << endl;
cout << endl;


return 0;
}



it doesn't work. It says f1 & f2 are unidentified.
This looks wrong
1
2
for (int x=0; x<3; x++)
	float f1, f2;

x, f1 and f2 will not exist outside the loop.
Last edited on
Could you post the EXACT error message and which line it refers to?
Also, put [code]code tags around your code[/code] to make it easier to read.
Topic archived. No new replies allowed.