for to while and if to switch conversion

Hello C++ forum users! Im here with another question for you, yet again!
Recently I have had a problem with converting for loops to while loops and if functions to switch functions. I was wondering if you could help me with these functions. The first one being the "for to while" conversion and the other one is the "if to switch" conversion.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
  for (i = 0; i < N; i += 2) a += i;

(^^^^^^^^ Converting this to while loop)

if (grade == 90)
printf (“Harf Notunuz: AA) ;
else if (grade == 80)
printf (“Harf Notunuz: BB) ;
else if (grade == 70)
printf (“Harf Notunuz: CC) ;
else if (grade == 60)
printf (“Harf Notunuz: DD) ;
else
printf (“Harf Notunuz: FF) ;

(^^^^^^^^^ Converting this to switch)


I have had my tries with these but I am just a newbie to the C language so the best place to come for help were you guys!
Thanks in advance!
Change line one to :

while( i < N )

For the switch add this before line five:

1
2
    switch( grade )
        {


Change line five to:

case 90:
Topic archived. No new replies allowed.