어레이
//AccessingAndModifyingArrayElements.cpp : 이 파일에는 'main' 함수가 포함되어 있습니다. 프로그램 실행은 그곳에서 시작하고 끝납니다.
//
"pch.h" 포함
포함
네임스페이스 표준 사용;
정수 메인()
{
//std::cout << "안녕하세요!\n";
//1. Accessing array elements
cout << "1. Accessing array elements : " << endl;
int arr[]{ 100, 20, 30, 50, 60 };
cout << "Array element 1: " << arr[0] << endl;
cout << "Array element 2: " << arr[1] << endl;
cout << "Array element 3: " << arr[2] << endl;
cout << "Array element 4: " << arr[3] << endl;
cout << "Array element 5: " << arr[4] << endl;
//2. Arrays are not check for out of bounds :
// Most probably code will crash in such situations.
//cout << "enter any number for arr[5] : " << endl;
//cin >> arr[5];
//3. Initializing array:
cout << "\n";
cout << "===============" << endl;
cout << "\n";
//int arr1[5];
//int arr2[5]{};
int arr3[5]{100, 90};
cout << "Array element 1: " << arr3[0] << endl;
cout << "Array element 2: " << arr3[1] << endl;
cout << "Array element 3: " << arr3[2] << endl;
cout << "Array element 4: " << arr3[3] << endl;
cout << "Array element 5: " << arr3[4] << endl;
//4. Modifying array elements
cout << "Enter 5 nums for arr3 : ";
cin >> arr3[0];
cin >> arr3[1];
cin >> arr3[2];
cin >> arr3[3];
cin >> arr3[4];
cout << "MOdified array : " << endl;
cout << arr3[0] << endl;
cout << arr3[1] << endl;
cout << arr3[2] << endl;
cout << arr3[3] << endl;
cout << arr3[4] << endl;
cout << "the value of array name is : " << arr3 << endl; // this shows the address value of 1st element of array.
return 0;
}
산출:
Reference
이 문제에 관하여(어레이), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://dev.to/vipuldeshmukh95/arrays-c25
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
네임스페이스 표준 사용;
정수 메인()
{
//std::cout << "안녕하세요!\n";
//1. Accessing array elements
cout << "1. Accessing array elements : " << endl;
int arr[]{ 100, 20, 30, 50, 60 };
cout << "Array element 1: " << arr[0] << endl;
cout << "Array element 2: " << arr[1] << endl;
cout << "Array element 3: " << arr[2] << endl;
cout << "Array element 4: " << arr[3] << endl;
cout << "Array element 5: " << arr[4] << endl;
//2. Arrays are not check for out of bounds :
// Most probably code will crash in such situations.
//cout << "enter any number for arr[5] : " << endl;
//cin >> arr[5];
//3. Initializing array:
cout << "\n";
cout << "===============" << endl;
cout << "\n";
//int arr1[5];
//int arr2[5]{};
int arr3[5]{100, 90};
cout << "Array element 1: " << arr3[0] << endl;
cout << "Array element 2: " << arr3[1] << endl;
cout << "Array element 3: " << arr3[2] << endl;
cout << "Array element 4: " << arr3[3] << endl;
cout << "Array element 5: " << arr3[4] << endl;
//4. Modifying array elements
cout << "Enter 5 nums for arr3 : ";
cin >> arr3[0];
cin >> arr3[1];
cin >> arr3[2];
cin >> arr3[3];
cin >> arr3[4];
cout << "MOdified array : " << endl;
cout << arr3[0] << endl;
cout << arr3[1] << endl;
cout << arr3[2] << endl;
cout << arr3[3] << endl;
cout << arr3[4] << endl;
cout << "the value of array name is : " << arr3 << endl; // this shows the address value of 1st element of array.
return 0;
}
산출:
Reference
이 문제에 관하여(어레이), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://dev.to/vipuldeshmukh95/arrays-c25텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)