Notice
Recent Posts
Recent Comments
Link
«   2025/03   »
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
Tags
more
Archives
Today
Total
관리 메뉴

archive

[C언어 실습/기컴프 과제] 7.6 본문

C \ C++/22_1 기컴프 (C)

[C언어 실습/기컴프 과제] 7.6

안정민 2022. 6. 21. 21:26

프로그래밍 연습 7.6

100명 사람들의 나이를 입력 받은 뒤 50세부터 60세에 속하는 사람들의 수를 구해주는 프로그램을 작성하시오. 단, for문과 continue 문을 사용하시오.

-

#include <stdio.h>

main()
{
    int age, sum, n;

    for (n = 0, sum = 0, age = 0; n <= 100; n += 1)
    {
        printf("Enter age: ");
        scanf_s("%d", &age);

        if (age >= 50 && age <= 60)
        sum += 1;


        else
        continue;

    }

    printf("Number of people between 50 and 60 is = %d", sum);

}

 

-