1. ## Do while

first off i would like to thank everyone for helping me with the previous problem, now this is another problem i have,

so far i think i did the right job, but i dont seem 2 know how 2 link two parts 2gether

Code:
```/*
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ IFT 1810 CD, automne 2007, TP # x                                     +
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ Auteur(s) : Amer Khayal                , section C                    +
+                                        , section D                    +
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ Ce programme permet de : convertir des livres en kilo ainsi que des   +
+ degres farenheit en celcius                                           +
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ Derni?re mise ? jour :  Mardi le 09 octobre 2007                      +
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
*/

#include <stdio.h>

int main(void)
{

int note;

printf("Entrez la note voulue (entre 0 et 100)");
scanf("%d", &note);

printf("\nLa note obtenue \n");
if(note>=0 && note<35)
printf("correspond a F");
else
if(note>=35 && note<50)
printf("correspond a E");
else
if(note>=50 && note<54)
printf("correspond a D");
else
if(note>=54 && note<57)
printf("correspond a D+");
else
if(note>=57 && note<60)
printf("correspong a C-");
else
if(note>=60 && note<65)
printf("correspond a C");
else
if(note>=65 && note<70)
printf("correspond a C+");
else
if(note>=70 && note<73)
printf("correspond a B-");
else
if(note>=73 && note<77)
printf("correspond a B");
else
if(note>=77 && note<80)
printf("correspond a B+");
else
if(note>=80 && note<85)
printf("correspond a A-");
else
if(note>=85 && note<90)
printf("correspond a A");
else
if(note>=90 && note<100)
printf("correspond a A+");
fflush(stdin);
getchar();
}```
yes as u all guess its a grading system

that was pretty easy i tried it and it worked but now comes the part i dot understand how to do.i m suppose 2 put in an equation, : avg= (exam1 x 0.20 + exam2 x 0.40) / 0.60

i m suppose 2 put that in so that while i doing the calculation of hte equation the answer will be given to me in number and letter.
but i dont know how 2 link it wih do while

Thank You for your time and help

2. Sounds like you need to ask the user for 2 numbers (the grades for the 2 exams). Then, your program calculates the average based on the above formula and then this average (numerical value) is displayed along with the letter grade of the calculated average according to the if/else-if structure you already have in place... which can be modified/simplified a bit to:
Code:
```if( note < 35 )
printf("correspond a F");
else if( note < 50 )
printf("correspond a E");
else if( note < 54 )
printf("correspond a D");
else if( note < 57 )
printf("correspond a D+");
else if( note < 60 )
printf("correspong a C-");
else if( note < 65 )
printf("correspond a C");
else if( note < 70 )
printf("correspond a C+");
else if( note < 73 )
printf("correspond a B-");
else if( note < 77 )
printf("correspond a B");
else if( note < 80 )
printf("correspond a B+");
else if( note < 85 )
printf("correspond a A-");
else if( note < 90 )
printf("correspond a A");
else if( note <= 100 )
printf("correspond a A+");```

And what does this have to do with do/while?

3. Because of the else statements, half of your expressions are redundant.
Code:
``` if(note>=0 && note<35)
printf("correspond a F");
else
if(note>=35 && note<50)
printf("correspond a E");```
By that point, note has to be >= 35; if it wasn't, the first if would have been executed.

that was pretty easy i tried it and it worked but now comes the part i dot understand how to do.i m suppose 2 put in an equation, : avg= (exam1 x 0.20 + exam2 x 0.40) / 0.60
 Never mind this section, I misread what you wanted to do. I've made it invisible text. Well, parsing expressions like that is a little complicated. Okay, very complicated. If you wanted to support expressions like that, you'd likely have to have a recursive function which parsed an expression in parentheses, unless you only wanted to support one level of them. You'd need some idea of operator precedence. You'd need some idea of variables, and a lookup table or a map or hash of sorts to store their values . . . . In other words, I think you're going to have to revise what you want to do. [/edit]

Code:
```  + Ce programme permet de : convertir des livres en kilo ainsi que des   +
+ degres farenheit en celcius                                           +```
I'm not familiar with that language, but your code doesn't look like it has anything to do with converting temperature to me.

Oh yes. Don't use fflush(stdin), it's undefined. http://faq.cprogramming.com/cgi-bin/...&id=1043284351

4. first off @ hk

i got the table

Xm1 Xm2
80.00 82.60
42.20 25.90
38.20 36.90
78.50 92.75

@dwks
i know because i just copy pasted it from another work i m doing...so i mguessin u speak french also...

i l was asked to find the avg of the to exams following the grades that were set up

how do i put the equation in? thats what i don't understand

do i have to restart program and ask in dos mode to input the number of exams, then the results of each exam, and then give an avg?

would that be the way t do it?

5. I don't think DWKS reads French very well, but just like me, he can recognize things like Fahrenheit and Celsius. I say this based on
I'm not familiar with that language, but your code doesn't look like it has anything to do with converting temperature to me
So, back to the original thoughts: If you had to calculate the average by hand, how would you do it?

How can you convert that to a program?

--
Mats

6. No, I don't read French very well. "degres farenheit en celcius" was a dead giveaway.

do i have to restart program and ask in dos mode to input the number of exams, then the results of each exam, and then give an avg?

would that be the way t do it?
Yes, something like that. For example, if you want to calculate this
Code:
`avg= (exam1 x 0.20 + exam2 x 0.40) / 0.60`
then the user needs to enter values for exam1 and exam2.

7. avg= (exam1 x 0.20 + exam2 x 0.40) / 0.60

by hand with the first of XM1 and the first of XM 2
(80*.20+82.60*.40)/.60=(16+33.04)/.60=81.73 &#37;
Code:
```(i know i m missing the beginning its because i dont know if i have to enter it with for the value of the 2 exams n the average( do i put float avg for it?)
float     or const(4 the exams...not sure tho....)

printf("Plz insert result to first exam");
scanf("%d",result1);
printf("plz inster result to second exam");
scanf("%F"result2);

avg=(result1 x 0.20 + result2 x 0.40) / 0.60

if( note < 35 )
printf("correspond a F");
else if( note < 50 )
printf("correspond a E");
else if( note < 54 )
printf("correspond a D");
else if( note < 57 )
printf("correspond a D+");
else if( note < 60 )
printf("correspong a C-");
else if( note < 65 )
printf("correspond a C");
else if( note < 70 )
printf("correspond a C+");
else if( note < 73 )
printf("correspond a B-");
else if( note < 77 )
printf("correspond a B");
else if( note < 80 )
printf("correspond a B+");
else if( note < 85 )
printf("correspond a A-");
else if( note < 90 )
printf("correspond a A");
else if( note <= 100 )
printf("correspond a A+");
i believe this is how it should be done, but i dont know how to link the result of the equation with the letter grading system
if i were 2 want 2 ask u 2 choose how many exams u would want 2 enter how would i present that?

Thanks Alot Guys

8. You want to use a float for your variables.

And then you want to use the average to select the grade, which you do with the long if/else statement.

Athough I would probably do something like this - but this may be beyond what you "know how to do at this level:
Code:
```struct gradeentry {
float limit;
{ {"F", 35.0f },
{"D", 54.0f },
{"D+", 57.0f },
{"C-", 60.0f },
{"C", 65.0f },
{"C+", 70.0f },
{"B-", 73.0f },
{"B", 77.0f },
{"B+", 80.0f },
{"A-", 85.0f },
{"A", 90.0f },
{"A+", 100.0f }
};

{
int i;
}
}```
--
Mats

9. Delete me - multiple post.

10. Delete me - multiple post.

12. yep to advanced for me i just started it 2 weeks ago :\$

i m gonna try n put 2gether wat u just showed me so i can see what happens

13. You should be able to delete your own posts, matsp. Click Edit->Delete This Post.

Might you want to print "the grade is :" before you print "correspond a A" or whatever, and not afterwards? And perhaps use better grammar while you're at it . . .

Code:
```printf("Plz insert result to first exam");
scanf("&#37;d",result1);
printf("plz inster result to second exam");
scanf("%F"result2);```
You're missing a comma, and %F is an invalid format specifier. Plus the input/ouput would look like this:
Code:
```Plz insert result to first exam80
plz inster result to second exam70```
In other words, print something like a space after the messages. Oh, and using a spell checker wouldn't hurt, either.

14. matsp, i m sorry i dont seem 2 understand how i m gonna put in the variables with float
mustn't i use const float first?

or do i start like so:

Code:
```
#include <stdio.h>

int main(void)
{

float exam1
float exam2
printf(Entre number of exams)
printf("Plz insert result to first exam");
scanf("&#37;d",result1);
printf("plz inster result to second exam");
scanf("%F"result2);

}```

is that how i should start it?

i am also asked in the same operation 2 calculate the WHOLE GRADE(that;s what they called it) : globale = 0.20 x intra + 0.40 x final + 0.40 x tps

its all 3 lists of exams.

so i think i have 2 restart programme and ask if it avg or whole grade....no?

15. @dwks

the program HAS 2 be in french lool....so im workin on it in french