tag:blogger.com,1999:blog-959939550345671470.post6029823786149576849..comments2024-03-24T12:51:18.535+05:30Comments on C programming Interview questions and answers: Write a c program to find out second smallest element of an unsorted arrayPriyanka kumarihttp://www.blogger.com/profile/08145649011863585828noreply@blogger.comBlogger7125tag:blogger.com,1999:blog-959939550345671470.post-20740822960172623322015-03-19T06:40:27.657+05:302015-03-19T06:40:27.657+05:30what about this input 4 50 2 60 30what about this input 4 50 2 60 30Anonymoushttps://www.blogger.com/profile/10169320451178669339noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-66857053503545997182015-02-16T13:35:34.623+05:302015-02-16T13:35:34.623+05:30//crack this function if you can.(0 is considered ...//crack this function if you can.(0 is considered as error, I mean you can't pass 0 from array)<br />#include <br /><br />int secsmall(int a[], int size){<br /> int s1 = a[0], s2, flg = 0, i;<br /> if(size < 2)<br /> return 0;<br /> for(i = 1; i < size; i++){<br /> if(flg){<br /> if(a[i] < s1){<br /> s2 = s1;<br /> s1 = a[i];<br /> }<br /> if(a[i] < s2 && a[iAnonymoushttps://www.blogger.com/profile/15052816756744134697noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-52405562148304197672013-10-26T23:29:13.031+05:302013-10-26T23:29:13.031+05:30i made it using only 1 for loop, check it out (tak...i made it using only 1 for loop, check it out (take array as input or declare it as you wish, already understood, i've declared)<br /><br />#include<br />int main()<br />{<br /> int a[]={5,2,1,0,7,8,-5,-8};<br /> int i,p=a[0],n=a[0],s=a[0];<br /> for(i=1;i<8;i++)<br /> {<br /> if(a[i]<n)<br /> n=a[i];<br /> if(s!=n)<br />Anonymoushttps://www.blogger.com/profile/07596993622296999767noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-48474572473817946262013-10-26T23:25:46.927+05:302013-10-26T23:25:46.927+05:30This comment has been removed by the author.Anonymoushttps://www.blogger.com/profile/07596993622296999767noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-30621677720874860162013-09-26T18:50:25.284+05:302013-09-26T18:50:25.284+05:30it is better to sort elements and find whatever we...it is better to sort elements and find whatever we want....(may increase complexity of prog(maybe n^2)) Anonymoushttps://www.blogger.com/profile/04172997457236692609noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-63524689449107978032013-05-22T10:53:06.926+05:302013-05-22T10:53:06.926+05:30*instead of 3*instead of 3coolbeehttps://www.blogger.com/profile/01554737620995036544noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-80930958801182827612013-05-22T10:48:38.095+05:302013-05-22T10:48:38.095+05:30it wont give the desired result if array is 3 2 8 ...it wont give the desired result if array is 3 2 8 7 5 it will print 5 as the second smallest no. instead of 2 hence loop for secondsmall shud begin with 0 instead of 1coolbeehttps://www.blogger.com/profile/01554737620995036544noreply@blogger.com