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 |
What is the purpose of the statement: strcat (S2, S1)?
what is array?
a=0; while(a<5) printf("%d\n",a++); how many times does the loop occurs? a.infinite b.5 c.4 d.6
write a program which will count occurance of a day between two dates.
What does c mean in standard form?
An instruction which is analysed and acted upon by the processor prior to the compiler going its work a) directive b) constructive c) constant d) absolute mode
How can I increase the allowable number of simultaneously open files?
related proverb of "dont count your chicken before it hatches"
how does a general function , that accepts an array as a parameter, "knows" the size of the array ? How should it define it parameters list ?
What is the size of enum in c?
Program to find largest of three numbers without using comparsion operator?
main() { FILE *fs; char c[10]; fs = fopen(“source.txt”, ”r”); /* source.txt exists and contains “Vector Institute” */ fseek(fs,0,SEEK_END); fseek(fs,-3L,SEEK_CUR); fgets(c,5,fs); puts(c); }