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 |
in any language the sound structure of that language depends on its a) character set, input/output function, its control structures b) character set, library functions, input/output functions its control structures c) character set, library functions, control sturctures d) character set, operators, its control structures
What is array in c with example?
What are void pointers in c?
a linearly ordered set of data elements that have the same structure and whose order is preserved in storage by using sequential allocation a) circular b) ordinary c) array d) linear list
What do you understand by normalization of pointers?
regarding pointers concept
what is memory leak?
Print the foll in C...eg when n=5 the o/p must b + + + + + + + + + + + + + + + + +
prototype of sine function.
for questions 14,15,16,17 use the following alternatives:a.int b.char.c.string.d.float
What is the benefit of using #define to declare a constant?
Write a c program to demonstrate character and string constants?