Ad

Chapter - 9: Arrays

Write a program using pointers to find the smallest number in an array of 25 integers.


Ad
I
Sections
3
Exercises
#include<stdio.h>
#include<conio.h>
int main()
{
	int arr[25], i;
	int min = arr[0];
	int *ptr;

	for (i = 0; i < 25; i++)
	{
		printf("\nEnter element %d : ", i + 1);
		scanf("%d", (ptr + i));
	}

	ptr = arr;
	for (i = 0; i < 25; i++)
	{
		if (*(ptr + i) < min)
			min = *(ptr + i);
	}
	printf("\nmin : %d", min);

	_getch();
	return 0;
}
Ad

© 2024 Garbage Valuegarbage value logo