Problem Description
Write a program to find Largest of three integer values using pointers
Input and Output Format:
Refer sample input and output for formatting specification.
All float values are displayed correct to 2 decimal places.
All text in bold corresponds to input and the rest corresponds to output.
Mandatory:
Use pointers conceptsTest Case 1
Input (stdin)3 4 3 1
Expected Output4 is largest
Test Case 2
Input (stdin)3 723 4444 123
Expected Output4444 is largest
Program
#include <stdio.h> int main() { int a[100],i,j,n,t,*b; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d",&a[i]); b=&a[i]; } for(i=0;i<n;i++) { for(j=i+1;j<n;j++) { if(a[i]>a[j]) { t=a[i]; a[i]=a[j]; a[j]=t; } } } b=&a[n-1]; printf("%d is largest",*b); return 0; }
No comments:
Post a Comment
Note: only a member of this blog may post a comment.