C Programming Tutorial 11, While Loop pt.1

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

U the man Keep updating and make shure it doesnt get deleted..thumbs up

m.mohammad
Автор

i++ means every time 1 is added with i.  What do i do if I want to add 2 with the current "i" everytime?

istiaqansari
Автор

Or you can do

    while(i <= 100)
        printf("%i\n", i++);

djleisheng
Автор

If someone struggles with the practice problem in the description.
Here is my approach.

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int counter=0;  //this counter is used to determinant how far in the alphabet we have gone.
    char abc = 65;  //The number 65 in a char equals the letter A. Number 66 equals B and so on.

        while (counter<26){     //here the program will print out the letter A and add +1 to the counter and the "abc" char. Next "abc" printf will show us the letter B.
                printf("\n %c", abc++, counter++);
        }
        while (counter>25&&counter<52){
                //In the next while loop the counter continues to count forward, but the "abc" char will be subtracted -1 by each time the program runs trough the loop.
                printf("\n %c", --abc, counter++);
        }
    return(0);
}

aishatheuglywifeoftheproph
join shbcf.ru