help plz!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include<iostream.h>
int main()
{
    int a, b=0, c, d, e;
    float f[7];
    cout<<"tell the operator\n";
    cin>>a;
    switch(a)
    {
    case 1:
         for(c=0;c<3;++c)
         {
         cout<<"enter the numbers\n";
         cin>>f[c];
         b=b+f[c];
         }
         cout<<"the sum is"<<b<<"\n";
         system("pause");
         case 2:
         cout<<"enter the numbers\n";
         cin>>f[0]>>f[1];
         b=f[0]*f[1];
         cout<<b;
         system("pause");
         case 3:         
         for(c=0;c<2;++c)
         {
         cout<<"enter the numbers\n";
         cin>>f[c];
         if(f[0]>=f[1])
         {
                       b=f[0]/f[1];
                       cout<<b;
                       system("pause");
                       }
                       else if(f[0]<=f[1])
                       {
                       b=f[1]/f[0];
                       cout<<b;
                       system("pause");
                       }
                       }
         }
         }
         return 0;
}

guyz i made dis program to work out the sum of 3 no.s and division etc, by d user's prefernce.
but i am getting a no. of mistakes plz tell me, where i am wrong!
ur furst misTAKE es that u spk like a 5 yr old chld.

Your second mistake is to use a compiler from before 1998. C++ has improved a lot in the last 15 years and you're not helping yourself by using an old, incorrect compiler.

An int divided by an int will give an int. What is 4/3? 1. What is 2/3? Zero.

WHat does your code not do that you think it should, and vice-versa? You can help yourself by asking specific questions rather than just "what's wrong".
sorry for my bad English. :(
actually i am not that poor in English! loll
i was just feeling too crappy at this time ( 3 am here!!!)
so i was lil ignorant while posting the question
anyway thanks , i got your point..
:)
and yup i am usin dev c++ 4.2
you must have gone mad at the system("pause").
sorry!
Last edited on
Topic archived. No new replies allowed.