Skip to content

Add Details #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions 10.w2.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#include <stdio.h>
#include <stdbool.h>

#define SIZE 4

int main(void)
{
int prices[SIZE] = { 100, 200, 300, 400 };

bool isTrue = true;
bool isFalse = false;

printf("True: %d, False: %d\n", isTrue, isFalse);

printf(" 'While' Loop:\n");

int i = 0;

while(i < SIZE)
{
printf("%d\n", prices[i]);
i++;
}

printf(" 'For' Loop:\n");

for (int i = 0; i < SIZE; i++)
{
printf("%d\n", prices[i]);
}

printf("Second 'For' Loop:\n");

for (int i = 0; i < SIZE; i++)
{
printf("%d\n", prices[i]);
}

// Если использовать одну инструкцию в теле while, for, if, else
// то фигурные скобки можно не писать
printf("For Loop Short Form:\n");

for (int i = 0; i < SIZE; i++) printf("%d\n", prices[i]);

printf("Do-While Loop:\n");

// Разница с while в том, что здесь тело цикла
// выполняется как минимум один раз: сначала выполняется,
// затем идет проверка условия
int j = 0;

do {
printf("%d\n", prices[j]);
j++;
} while(j < SIZE); // обратить внимание на точку с запятой!

return 0;
}
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
####Linux程序设计学习代码
Email:
Contact:
Linkedin: