Notice
Recent Posts
Recent Comments
Creative Code
findValueinArray.c( 배열에서 값 찾기) 본문
#include <stdio.h>
int main(void)
{
int nums[10] = {50,90,30,100,80,10,20,40,70,60};
printf("찾을 숫자 : ");
int value;
scanf("%d",&value);
int check=0;
int i;
for (i = 0; i<10; i++){
if (value == nums[i]){
break; // break를 걸면 반복문을 빠져나간다.
}
}
if (i<10) {
printf("%d is found. index : %d\n",value,i);
} else {
printf("%d is not found",value);
}
return 0;
}
'C Programming' 카테고리의 다른 글
selectionSorting.c (배열 값 정렬) (0) | 2023.08.02 |
---|---|
swap.c(두 수 바꾸기) (0) | 2023.08.02 |
findvalue.c(배열에서 값의 존재여부) (0) | 2023.08.01 |
findMAxArray.c(배열 최댓값 구하기) (0) | 2023.08.01 |
sumArray.c(배열 값 더하기) (0) | 2023.08.01 |