Skip to content

Commit 9b20840

Browse files
authored
Print the number using pointer
Write a C++ program to accept a set of 10 numbers and print the numbers using pointers.
1 parent c908b4b commit 9b20840

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

using_pointer.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#include <iostream>
2+
3+
int main() {
4+
int num_arr[10], *ptr;
5+
std::cout << "Enter 10 numbers : \n";
6+
for (int i = 0; i < 10; i++)
7+
{
8+
std::cin >> num_arr[i];
9+
}
10+
ptr = &num_arr[0];
11+
std::cout << "\nOutput : \n";
12+
for (int i = 0; i < 10; i++)
13+
{
14+
std::cout << *ptr << std::endl;
15+
ptr++;
16+
}
17+
return 0;
18+
}

0 commit comments

Comments
 (0)