C language tricky good pointers questions answers and explanation operators data types arrays structures questions functions recursion preprocessors, looping, file handling, strings questions switch case if else printf advance c linux objective types mcq faq interview questions and answers with explanation and solution for freshers or beginners. Placement online written test prime numbers Armstrong Fibonacci series factorial palindrome code programs examples on c c++ tutorials and pdf

Fantastic site!!
ReplyDeleteThank you very much...
Subha
hey Jason, here is the code:
ReplyDeleteif(a[i]>max)
{
max2=max;
max=a[i]}
}
else if(a[i]>max2)
{
max2=a[i];
}
i fixed the code.
ReplyDeleteif(a[i]>max)
{
max2=max;
max=a[i]}
}
else if(a[i]>max2&&a[i]!=max)
{
max2=a[i];
}
and here's how you find the third and the fourth largest numbers.
min=num[0];
for(i=1;inum[i])
min=num[i];
}
max=min;
max2=min;
max3=min;
max4=min;
for(i=0;imax)
{
max4=max3;
max3=max2;
max2=max;
max=num[i];
}
else if(num[i]>max2&&num[i]!=max)
max2=num[i];
else if(num[i]>max3&&num[i]!=max2&&num[i]!=max)
max3=num[i];
else if(num[i]>max4&&num[i]!=max3&&num[i]!=max2&&num[i]!=max)
max4=num[i];
}
Woops, got some typos there.
ReplyDeletemin=num[0];
for(i=1;inum[i])
min=num[i];
}
lol something's wrong here, but you get the concept.
ReplyDeleteKindly answer this prob...if i want to find out the position of the largest number in an array than how to find it???..thnx in advance =)
ReplyDeleteTo find out the largest element array. I think following link will help you.
ReplyDeletehttp://cquestionbank.blogspot.com/2008/01/write-c-program-to-find-largest-number.html
to find nthbiggest... pseudo code...
ReplyDeletecorrect me i it has errors..
static int k = 0; // golbal
void main()
{
int i, j,size,n,nthbig;
int arr[];
\\enter nth heighest...
for(i=1;i<=n;i++)
nthbig=selectbig();
}
int selectbig()
{
int temp;
big=a[0];
for(i=k;i<size;i++)
{
if(big<a[i])
big=a[i];
}
temp = a[i];
a[i]=a[k];
a[k]=temp;
k++;
return big;
}
but how do we create the algorithm
ReplyDeletethank u
ReplyDeletevery good
ReplyDeleteWrite a program that accepts five numbers from the user and displays the highest and lowest number. Assume that there are no duplicate values.
ReplyDeleteUse the technique of bubble sorting
ReplyDeletefor(i=0;i<=1;i++){
for(j=0;ja[j+1]){
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
printf("%d",a[n-1]);
}
with respect to the code for finding out the second highest number, correct output is not being given for the following set of inputs:
ReplyDelete4,4,3..Please help!
in this program secondbig=a[size-j] not a[size-j-1]....tyhen this works fine for the input 1 5 2 3 4
ReplyDeletein this program secondbig=a[size-j] not a[size-j-1]....tyhen this works fine for the input 1 5 2 3 4
ReplyDeleteguys how to do it without sorting the array
ReplyDeleteHi think this program is wrong ..pls verify ....
ReplyDeleteThis comment has been removed by the author.
ReplyDeletehey bro, go'g to do Mini project on this sem ,am do'g mca , plz suggest a live project . . .its instance.
ReplyDeletesec_big=arr[0];
ReplyDeletefor(i=0;isec_big)&&(sec_big<big))
{
sec_big=arr[i];
}
}
This comment has been removed by the author.
ReplyDeleteThis comment has been removed by the author.
ReplyDelete#include
ReplyDeletemain()
{
int a[] = {9000, 90, 6, 20, 54, 1000, 23, 58,12, 500};
int i, fl, sl;
fl =a[0]; sl = a[0];
for(i = 1; i < 10; i++)
{
if(fl < a[i])
{
sl = fl;
fl = a[i];
}
else if (sl < a[i])
sl = a[i];
else if (sl == fl && sl > a[i])
sl = a[i];
}
printf("FL = %d \n SL = %d", fl, sl);
}
#include
ReplyDeletemain()
{
int a[] = {9000, 90, 6, 20, 54, 1000, 23, 58,12, 500};
int i, fl, sl;
fl =a[0]; sl = a[0];
for(i = 1; i < 10; i++)
{
if(fl < a[i])
{
sl = fl;
fl = a[i];
}
else if (sl < a[i])
sl = a[i];
else if (sl == fl && sl > a[i])
sl = a[i];
}
printf("FL = %d \n SL = %d", fl, sl);
}
reach me for queries at raavi.kishore@gmail.com
it is nice
ReplyDeleteplease help me out to correct the programme
ReplyDeletehere the coding
// Program-13
//Aim-To search a element from an array
#include
#include
void main()
{
int a[50],i,j,s,flag=1,pos; clrscr();
printf("How many numbers do you want to enter (max 50)");
scanf("%d",&i);
printf("Enter the numbers\n");
for(j=0;j<i;j++)
{
scanf("%d",&a[j]);
}
printf("Enter the element you want to search ");
scanf("%d",&s);
for(j=0;j<i;j++)
if(a[j]==s)
{
flag=1;
pos=j;
}
else
{
flag=0;
}
if(flag==1)
{
printf("Element is found at %d position",pos+1);
}
else
{
printf("Element is not found");
}
getch();
}
guys i need a program to find second largest after sorting the array pls help me out...
ReplyDeleteAbove programe "find the second largest element in an array" will produce wrong value if u Enter elements in array {4,5,3,2,1}. Try it
ReplyDeletein the above program should be initilalised as
Deletesecondbig=a[0];//correct
not as
secondbig=a[size-j-1];//incorrect
YOU well GEt correct output
in the above program should be initilalised as
ReplyDeletesecondbig=a[0];//correct
not as
secondbig=a[size-j-1];//incorrect
hi, this doesn't work for me when the biggest value is the first.
Delete