ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip   SiteMap shows list of All Categories in this site.
Google
 
Categories  >>  Software  >>  Programming Languages  >>  C
 
 


 

 
 C interview questions  C Interview Questions
 C++ interview questions  C++ Interview Questions
 VC++ interview questions  VC++ Interview Questions
 Delphi interview questions  Delphi Interview Questions
 Programming Languages AllOther interview questions  Programming Languages AllOther Interview Questions
Question
write a program to arrange the contents of a 1D array in 
ascending order
 Question Submitted By :: Priyanka
I also faced this Question!!     Rank Answer Posted By  
 
  Re: write a program to arrange the contents of a 1D array in ascending order
Answer
# 1
int main()
{
        int a[20],n,i,j,temp;
        printf("Enter the size of an array : ");
        scanf("%d",&n);
        printf("Enter the array elements : ");
        for(i=0;i<n;i++)
        {
                scanf("%d",&a[i]);
        }
        for(i=0;i<n;i++)
        {
                for(j=i;j<n;j++)
                {
                        if(a[i]>a[j])
                        {
                                temp=a[j];
                                a[j]=a[i];
                                a[i]=temp;
                        }
                }
        }
        printf("\nAscending Order\n");
        for(i=0;i<n;i++)
        {
                printf("%d\n",a[i]);
        }
        return 0;
}
 
Is This Answer Correct ?    13 Yes 5 No
Poornima
 
  Re: write a program to arrange the contents of a 1D array in ascending order
Answer
# 2
int main()
{
        int a[20],n,i,j,temp;
        printf("Enter the size of an array : ");
        scanf("%d",&n);
        printf("Enter the array elements : ");
        for(i=0;i<n;i++)
        {
                scanf("%d",&a[i]);
        }
    printf("\nAscending Order\n");
        for(i=0;i<n;i++)
        {
                for(j=i;j<n;j++)
                {
                        if(a[i]>a[j])
                        {
                                temp=a[j];
                                a[j]=a[i];
                                a[i]=temp;
                        }
                }
         printf("%d\n",a[i]);
        }
        return 0;
}
 
Is This Answer Correct ?    5 Yes 5 No
Kameshav
 
 
 
  Re: write a program to arrange the contents of a 1D array in ascending order
Answer
# 3
#include<stdio.h>
#include<conio.h>
void main()
{
int a[20],n,i,j,temp;
clrscr();
printf("\n enter the size of  the array");
scanf("%d",&n);
printf("\n enter the contents of the array");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<n;i++)
 {
  for(j=0;j<(n-1)-i;j++)
   {
    if(a[j]>a[j+1])
     {
      temp=a[j];
      a[j]=a[j+1];
      a[j+1]=temp;
     }
   }
 }
getch();
}
 
Is This Answer Correct ?    0 Yes 1 No
Rajeev
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
What is function pointer and where we will use it NetApp1
How to implement call back functions ? HP2
Name the language in which the compiler of "c" in written? Bajaj1
Software Interview Questions CAT1
what is disadvantage of pointer in C Tech-Mahindra5
what is the size of an integer variable?  1
#include <stdio.h> int main ( int argc, char* argv [ ] ) { int value1 = 10; int value2 = 5; printf ( "\n The sum is :%d", value1 | value2 ); } This is the answer asked by some one to add two numbers with out using arithmetic operator?Yes this answer is write it given out put as 15.But how????? what is need of following line? int main ( int argc, char* argv [ ] ) how it work?what is the meaning for this line? please explain me.Advance thanks Excel4
why i join syntel? Syntel12
wap in c to accept a number display the total count of digit  4
what are the various memory handling mechanisms in C ? HP3
who will call your main function in c under linux?  2
write a recursive program in'c'to find whether a given five digit number is a palindrome or not  1
write a program to find out number of on bits in a number? Huawei12
do ne body have any idea about the salary for the we r going to have interview. yup .. u got it right ..i m talking abt NIC.  1
dynamically allocate memory for linear array of n integers,store some elements in it and find some of them  1
print ur name without using any semicolon in c/c++....  6
If we have an array of Interger values, find out a sub array which has a maximum value of the array and start and end positions of the array..The sub array must be contiguious. Take the start add to be 4000. For Ex if we have an array arr[] = {-1,-2,-5,9,4,3,-6,8,7,6,5,-3} here the sub array of max would be {8,7,6,5} coz the sum of max contiguous array is 8+7+6+5 = 26.The start and end position is 4014(8) and 4020(5). Microsoft4
Write code for atoi(x) where x is hexadecimal string. Adobe2
write a program for even numbers?  8
differentiate between const char *a; char *const a; and char const *a; HCL1
 
For more C Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com