In this example, mark[0] is the first element. If the size of an array is n, to access the last element, the n-1 index is used. In this example, mark[4] Suppose the starting address of mark[0] is 2120d. Then, the address of the mark[1] will be 2124d. Similarly, the ...
#include <iostream> using namespace std; int main() { int n, i; float num[100], sum=0.0, average; cout << "Enter the numbers of data: "; cin >> n; while (n > 100 || n <= 0) { cout << "Error! number should in range of (1 to 100)." << endl; cout << "Enter ...
Finally, we print the array elements in each iteration. Example 2: Taking Input for Two Dimensional Array #include<iostream>usingnamespacestd;intmain(){intnumbers[2][3];cout<<"Enter 6 numbers: "<<endl;// Storing user input in the arrayfor(inti =0; i <2; ++i) {for(intj =0; j ...
// C++ Program to insert and display data entered by using pointer notation.#include<iostream>usingnamespacestd;intmain(){floatarr[5];// Insert data using pointer notationcout<<"Enter 5 numbers: ";for(inti =0; i <5; ++i) {// store input number in arr[i]cin>> *(arr + i) ; }...
Pass arrays to a function in C Share on: Did you find this article helpful? Our premium learning platform, created with over a decade of experienceand thousands of feedbacks. Learn and improve your coding skills like never before. Try Programiz PRO...
Certification courses in Python, Java, SQL, HTML, CSS, JavaScript and DSA. Try Programiz PRO! Tutorials Examples Courses Try Programiz PRO Introduction to C++ Getting Started With C++ Your First C++ Program C++ Comments C++ Fundamentals C++ Keywords and Identifiers C++ Variables, Literals and ...