This is a C++ program that declares an integer array of size 5 called marks and initializes it with some values. It then calls a function called display and passes the marks array as an argument.
The display function takes an array of integers as its argument and prints the marks of 5 students, along with their student number (starting from 1).
Note that the function display takes the array as an argument using the syntax int m[5], which is equivalent to int *m. This means that the function receives a pointer to the first element of the array, and it can access the other elements using pointer arithmetic.
#include <iostream> using namespace std; void display(int m[5]) { cout<<"Displaying marks: "<<endl; for (int i=0;i<5;++i) { cout<<"Student "<<i+1<<": "<<m[i]<<endl; } } int main() { int marks[5] = {88,76,90,61,69}; display(marks); return 0; }To download raw file Click Here
Displaying marks: Student 1: 88 Student 2: 76 Student 3: 90 Student 4: 61 Student 5: 69
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions