Program to swap the any two elements in an array containing N number of elements?
#include<stdio.h>
void swaparray(int *,int *);
void main()
{
int n,num[10],i,element,k,l;
printf("Enter number of elements
");
scanf("%d",&n);
printf("Enter the elements
");
for(i=0;i<n;i++)
{
scanf("%d",&element);
num[i]=element;
}
printf("Original array
");
for(i=0;i<n;i++)
printf("num[%d]=%d
",i,num[i]);
printf("ENter places to be swapped");
scanf("%d%d",&k,&l);
swaparray(num+k,num+l);
printf("AFTER SWAPPING
");
for(i=0;i<n;i++)
printf("num[%d]=%d
",i,num[i]);
}
void swaparray(int *a, int *b)
{
int temp;
temp = *a;
*a = *b;
*b = temp;
}
Is This Answer Correct ? | 7 Yes | 1 No |
Which is more efficient, a switch statement or an if else chain?
In a header file whether functions are declared or defined?
print the following using nested for loop. 5 4 3 2 1 1 2 3 4 3 2 1 1 2 1 2 1 1 2 3 4 3 2 1 1 2 3 4 5
#include<conio.h> #include<stdio.h> void main() { int i; if(1,0,2,3) { printf("if"); } else { printf("else"); } getch(); } Can any body tell the answer of this question with explanation?
disply the following menu 1.Disply 2.Copy 3.Append; as per the menu do the file operations 4.Exit
Explain what math functions are available for integers? For floating point?
what is the difference between entry control and exit control statement?
12 Answers Darbari Lal DAV Model School,
write a program to sort the elements in a given array in c language
What is structure in c definition?
What is calloc malloc realloc in c?
what does static variable mean?
a sequence of bytes with one to one corrspondence to those in the external device a) sequential addressing b) address c) byte code d) none