WAP to read 'n' numbers and print the biggest and smallest number. Pls help me with this. The program should be done with without using arrays.......
Nandu Das
0
Newbie Poster
Recommended Answers
Jump to Post#include<iostream.h> #include<conio.h> void main() { int arr[20],temp,cnt,cnt2,small,num; clrscr(); cout<<"how many elements you want to insert for sorting:"; cin>>num; cout<<"\nenter elements:"; for(cnt=0;cnt<num;cnt++) cin>>arr[cnt]; for(cnt=0;cnt<num-1;cnt++) { small=cnt; for(cnt2=cnt+1;cnt2<num;cnt2++) { if(arr[small]>arr[cnt2]) small=cnt2; } if(small!=cnt) { temp=arr[small]; arr[small]=arr[cnt]; arr[cnt]=temp; } } cout<<"\nsorted elements"; for(cnt=0;cnt<num;cnt++) cout<<" " <<arr[cnt]; cout<<"\n\nsmallest number is:"<<arr[0]; cout<<"\nbiggest …
All 2 Replies
Reply to this topic
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.