OUTPUT (after running):
Enter the size of vector: 6
Enter the vector elements: 1.00 2.00 1.00 3.00 2.00 4.00
Vector has two duplicates
Vector after deleting duplicates
1.00 2.00 3.00 4.00
Example
12: Write a C program to insert an element into the vector array.
Solution 12:
The program is as follows:
#include
main( )
{
int i, j, k, n, pos;
float a[80], item;
printf(“\nEnter the size of vector: “);
scanf(“%d”, &n);
printf(“%d”, n);
printf(“\n Enter the vector elements:\n”);
for (i=0; i scanf(“%f”, &a[i]);
for(i=0; i printf(“%f”, a[i]);
printf(“\n);
/* inserting element */
printf(“\n Enter the element to be inserted:”);
scanf(“%d”, &item);
printf(“%d”, item);
printf(“\n Enter the position of insertion:”);
scanf(“%d”, &pos);
printf(“%d”, item);
Do'stlaringiz bilan baham: |