LAB-1 Assignment
LAB-1 Assignment
2022-1-60-029
Cse207 (MMLI)
Section = 8
Exercise 1:
Modify the above code to count the number
of pass and swap operation for an array of
size N.
ANS :
#include <stdio.h>
int main(){
int a[100];
int n,i,pos=-1,item,passes = 0,swaps = 0;
printf("Enter number of elements: ");
scanf("%d",&n);
printf("Enter your data : ");
for(i = 0; i < n; i++){
scanf("%d",&a[i]);
}
}
OUTPUT :
Exercise 2
Write a program to find second maximum
and minimum number of an integer array. Show the
sample input and output clearly.
#include<stdio.h>
int main(){
int
num,i,largest,second_largest,smallest,second_smalles
t;
printf("How many elements you want :");
scanf("%d",&num);
if(num<2){
printf("Warning ! The array should have atleast
2 elements .");
return;
}
int arr[num];
printf("Enter your data :");
for( i=0 ;i<num;i++){
scanf("%d",&arr[i]);
}
largest = arr[0];
second_largest=0;
return 0;
}
Output :