write a program to sort the elements in a given array in c
language
Answer Posted / naga tirupathi rao
#include<stdio.h>
#include<conio.h>
main()
{
int a[25],i,n,sum=0;
clrscr();
prinf("enter the size of array");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
printf("element%d=",i);
scanf("%d",&a[i]);
sum=sum+a[i];
}
printf("ascending orderis:");
for(j=0;j<=sum;j++)
{
for(i=1;i<=n;i++)
{
if(j==a[i])
printf("%d",j);
}
}
getch();
}
| Is This Answer Correct ? | 22 Yes | 15 No |
Post New Answer View All Answers
What is the auto keyword good for?
write a proram to reverse the string using switch case?
What is the purpose of ftell?
What is a structure and why it is used?
using only #include
Which is more efficient, a switch statement or an if else chain?
What does stand for?
Can a variable be both static and volatile in c?
Is it possible to pass an entire structure to functions?
Define Array of pointers.
The statement, int(*x[]) () what does in indicate?
What is the use of header files?
which of the following statement is wrong a) mes=123.56; b) con='T'*'A'; c) this='T'*20; d) 3+a=b;
You have given 2 array. You need to find whether they will
create the same BST or not.
For example:
Array1:10 5 20 15 30
Array2:10 20 15 30 5
Result: True
Array1:10 5 20 15 30
Array2:10 15 20 30 5
Result: False
One Approach is Pretty Clear by creating BST O(nlogn) then
checking two tree for identical O(N) overall O(nlogn) ..we
need there exist O(N) Time & O(1) Space also without extra
space .Algorithm ??
DevoCoder
guest
Posted 3 months ago #
#define true 1
#define false 0
int check(int a1[],int a2[],int n1,int n2)
{
int i;
//n1 size of array a1[] and n2 size of a2[]
if(n1!=n2) return false;
//n1 and n2 must be same
for(i=0;i
C program execution always begins with a) #include b) comment (/*-------*/) c) main() d) declaration instructions