max and min number

max and min number - printf("\n enter a[ %d ]=...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Q: write a program to scan and print an array of 10 element then replace the location of max number by the location of min number in array ? #include<iostream.h> #include<stdio.h> void main() { int min,max,imax,imin,a[10]; imax=imin=0; for (int i=0;i<10;i++) { printf("\n enter a[ %d ]",i); scanf("%d",&a[i]); } for (i=0;i<10;i++) {
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: printf(&quot;\n enter a[ %d ]= %d &quot;,i,a[i]); } min=max=a[0]; for (i=1;i&lt;10;i++) { if(a[i]&lt;min){ min=a[i]; imin=i;} else if(a[i]&gt;max){ max=a[i]; imax=i; } } printf(&quot;max = a[%d] = %d \n min = a[%d]= %d&quot;,imax,max,imin,min); a[imax]=min; a[imin]=max; for (i=0;i&lt;10;i++) { printf(&quot;\n enter a[ %d ]= %d &quot;,i,a[i]); }...
View Full Document

This note was uploaded on 10/16/2010 for the course ENG 2266e taught by Professor Aliraqi during the Spring '10 term at 4.1.

Page1 / 2

max and min number - printf(&amp;amp;quot;\n enter a[ %d ]=...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online