Answer of Program
Answer of Program
Write a JavaScript function to swap/exchange two numbers using botton void sortEmployees(struct Employee emp[], int n) {
click event for (int i = 0; i < n - 1; i++) {
<button id="swap">Click me</button> for (int j = 0; j < n - i - 1; j++) {
<input id="one" value="One"/> if (emp[j].salary < emp[j + 1].salary) {
<input id="two" value="Two"/> swap(&emp[j], &emp[j + 1]);
}
<script> }
var btn = document.getElementById("swap"); }
btn.addEventListener("click", function(e) { }
var from = document.getElementById("one"),
to = document.getElementById("two"); int main() {
if(!!from && !!to) { int n;
var _ = from.value; printf("Enter number of employees: ");
from.value = to.value; scanf("%d", &n);
to.value = _;
} else { struct Employee emp[n];
console.log("some input elements could not be found");
} // Input employee details
}); for (int i = 0; i < n; i++) {
</script> printf("\nEnter details for employee %d:\n", i + 1);
printf("ID: ");
Q. Write a C program using structure to input employee's id, name and salary scanf("%d", &emp[i].id);
then print the entered data in sorted order based on salary(from highest to printf("Name: ");
lowest) in simple way scanf(" %49[^"]", emp[i].name); // Read string with spaces
printf("Salary: ");
#include <stdio.h> scanf("%f", &emp[i].salary);
#include <string.h> }
struct Book {
char name[100];
float price;
int edition;
};
int main() {
struct Book book;
FILE *file = fopen("hissan.txt", "a+");
if (!file) {
printf("Error opening file!\n");
return 1;
}
return 0;
}