hello ; check this program please , when i enter -1 to endthe program
its give me wrong grade (enter number between 0 and 100)!!
and is my way to find the maximum value between numbers input by user right ?
thanks in advance :)
line 16 and 36: you set min and max to a[0], but a[0]] has no value yet. a[0] gets the user's input in the following loop.
i'd add another function for the input of the 10 numbers and the 12 numbers. save the input in 2 arrays. then call the min and max functions with the corresponding array and return the min, max value to print it on the screen.
#include <iostream>
usingnamespace std;
int t,input;
double sort(int a[],int size);
int main()
{
int array[100];
sort(array,100);
cout << "elements=" << input<< endl;
return 0;
}
double sort(int a[],int size)
{
cout << "enter the numbers please:\n" ;
for (int i=0;i<size;i++)
{
for (int p=size-1;p<=i;p--)
if(a[i]>a[p])
{
a[p]=input;
a[p]=a[i];
input=a[i];
}
}
return input;
}
how can let the user enter the values (inputs) , and then the program sort the valuse from minimum to maximum ,and then print on the screen ? and why evertime i run this code , its terminate the code::blocks ?
how can let the user enter the values (inputs) , and then the program sort the valuse from minimum to maximum ,and then print on the screen ?
Nobody wants to rewrite the book you should be reading. If you have problem with code that you're writing, by all means, ask for help. If you need a tutorial, find one or read your book or study material until you're able to attempt code doing what you want. If you supply no code attempting to do what you want, and then ask why you're not getting any help, it's because we put the same effort into helping you as you do into trying to code.
cire , iam rly confused , some ppl here told me if u have some problems in a code i can ask for help , if any one can find the answers in the book i would sugest to close the beginners forum .
NwN , thank you u helped me alot but we r not allowed to use the logic (std::) :) .
this means that you can replace std::cout and std::cin with simply cout and cin in NwN's
function.
ignore cire, there are always these guys with a bunch of posts on forums who dont want to give easy answers cause they spent a bunch of time learning stuff on their own and think people are lazy when they don't do the same - they think books and stuff first then ask people. Sure that's fine (thats what I did - been programming for over 10 years with a couple complete Apps to my name) but you have posted code and asked what's wrong with it. I see that you most likely wrote it yourself cause its beginner style coding so..
dreamincolor , thank you for your support , i understand that book should my first refernce , but most thing in book we didnt take it with our doctor , so after i finish my exam i will study from the book and if i have any question i will ask here :) .