#include <stdio.h>
#include <math.h>
#define N 1000000
#define PI 3.141592653589793
double f1(double x) {
return 5.0 * (1 - cos(2 * x));
}
double f2(double x) {
return 5.0 * pow(log(x + 1), 2) / (x + 1);
}
double f3(double x) {
return exp(PI - x) / sqrt(x * x + 1);
}
double simpsons_rule(double (*func)(double), double a, double b, int n) {
if (n % 2 != 0) {
printf("Error: N must be even.\n");
return -1;
}
double h = (b - a) / n;
double sum = func(a) + func(b);
for (int i = 1; i < n; i += 2) {
double x = a + i * h;
sum += 4.0 * func(x);
}
for (int i = 2; i < n; i += 2) {
double x = a + i * h;
sum += 2.0 * func(x);
}
return (h / 3.0) * sum;
}
int main() {
double integral1 = 5.0 * PI / 2.0;
double integral2 = simpsons_rule(f2, 0, PI, N);
double integral3 = simpsons_rule(f3, 0, PI, N);
double result = integral1 - integral2 + integral3;
printf("Integral 1 : %.10f\n", integral1);
printf("Integral 2 : %.10f\n", integral2);
printf("Integral 3 : %.10f\n", integral3);
printf("By solving all equation:( %.10f-%.10f+%.10f)\n", integral1,integral2,integral3);
printf("your age is approximately : %.10f\n", result);
return 0;
}
#include <math.h>
#define N 1000000
#define PI 3.141592653589793
double f1(double x) {
return 5.0 * (1 - cos(2 * x));
}
double f2(double x) {
return 5.0 * pow(log(x + 1), 2) / (x + 1);
}
double f3(double x) {
return exp(PI - x) / sqrt(x * x + 1);
}
double simpsons_rule(double (*func)(double), double a, double b, int n) {
if (n % 2 != 0) {
printf("Error: N must be even.\n");
return -1;
}
double h = (b - a) / n;
double sum = func(a) + func(b);
for (int i = 1; i < n; i += 2) {
double x = a + i * h;
sum += 4.0 * func(x);
}
for (int i = 2; i < n; i += 2) {
double x = a + i * h;
sum += 2.0 * func(x);
}
return (h / 3.0) * sum;
}
int main() {
double integral1 = 5.0 * PI / 2.0;
double integral2 = simpsons_rule(f2, 0, PI, N);
double integral3 = simpsons_rule(f3, 0, PI, N);
double result = integral1 - integral2 + integral3;
printf("Integral 1 : %.10f\n", integral1);
printf("Integral 2 : %.10f\n", integral2);
printf("Integral 3 : %.10f\n", integral3);
printf("By solving all equation:( %.10f-%.10f+%.10f)\n", integral1,integral2,integral3);
printf("your age is approximately : %.10f\n", result);
return 0;
}
Here is an example of how you can use the Tone.js library to create a simple oscillator that plays a musical tone in an HTML document:
In this example, Tone.js is used to create a simple synthesizer that plays a musical tone when a button with the id "playButton" is clicked. The tone played is a 'C4' note with a duration of '8n'. You can customize the note and duration according to your preferences.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Tone.js Example</title>
<script src="https://cdn.jsdelivr.net/npm/tone"></script>
<script>
// Create a new Tone.js oscillator
const synth = new Tone.Synth().toDestination();
// Play a musical tone when the button is clicked
document.getElementById('playButton').addEventListener('click', () => {
synth.triggerAttackRelease('C4', '8n');
});
</script>
</head>
<body>
<button id="playButton">Play Tone</button>
</body>
</html>
In this example, Tone.js is used to create a simple synthesizer that plays a musical tone when a button with the id "playButton" is clicked. The tone played is a 'C4' note with a duration of '8n'. You can customize the note and duration according to your preferences.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Image Search</title>
</head>
<body>
<!-- Custom Image Tags with Search Functionality -->
<img src="cats" type="search" alt="Search result image">
<img src="dogs" type="search" alt="Search result image">
<img src="birds" type="search" alt="Search result image">
<script>
// Function to fetch the first image from the new API
async function fetchImage(searchTerm) {
try {
const response = await fetch(
if (response.ok) {
const data = await response.json();
if (data && data.length > 0) {
return data[0]; // Return the URL of the first image
}
}
return null;
} catch (error) {
console.error('Error fetching image:', error);
return null;
}
}
// Compiler function to process <img type="search">
async function compileSearchImages() {
const searchImages = document.querySelectorAll('img[type="search"]');
searchImages.forEach(async (img) => {
const searchTerm = img.getAttribute('src');
const imageUrl = await fetchImage(searchTerm);
if (imageUrl) {
img.src = imageUrl; // Replace the src with the fetched image URL
} else {
img.alt = 'No image found'; // Handle case where no image is found
}
});
}
// Run the compiler when the document is loaded
document.addEventListener('DOMContentLoaded', compileSearchImages);
</script>
</body>
</html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Image Search</title>
</head>
<body>
<!-- Custom Image Tags with Search Functionality -->
<img src="cats" type="search" alt="Search result image">
<img src="dogs" type="search" alt="Search result image">
<img src="birds" type="search" alt="Search result image">
<script>
// Function to fetch the first image from the new API
async function fetchImage(searchTerm) {
try {
const response = await fetch(
https://api.kastg.xyz/api/search/google-image?q=${searchTerm});if (response.ok) {
const data = await response.json();
if (data && data.length > 0) {
return data[0]; // Return the URL of the first image
}
}
return null;
} catch (error) {
console.error('Error fetching image:', error);
return null;
}
}
// Compiler function to process <img type="search">
async function compileSearchImages() {
const searchImages = document.querySelectorAll('img[type="search"]');
searchImages.forEach(async (img) => {
const searchTerm = img.getAttribute('src');
const imageUrl = await fetchImage(searchTerm);
if (imageUrl) {
img.src = imageUrl; // Replace the src with the fetched image URL
} else {
img.alt = 'No image found'; // Handle case where no image is found
}
});
}
// Run the compiler when the document is loaded
document.addEventListener('DOMContentLoaded', compileSearchImages);
</script>
</body>
</html>
Hello! 👋 How can I assist you with your HTML coding today? Whether you need help with syntax, layout, or anything else, feel free to ask!
index.html
2.5 KB
100% working 3d model in html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Device Info</title>
</head>
<body>
<h1>Device Information</h1>
<div id="device-info"></div>
<script>
// Function to get basic device information from User-Agent
function getDeviceInfo() {
const ua = navigator.userAgent;
let deviceInfo = {
browser: navigator.appName,
browserVersion: navigator.appVersion,
userAgent: ua,
platform: navigator.platform,
language: navigator.language
};
// Detect mobile device type from User-Agent
if (/android/i.test(ua)) {
deviceInfo.deviceType = "Android";
} else if (/iPhone|iPad|iPod/i.test(ua)) {
deviceInfo.deviceType = "iOS";
} else if (/Windows Phone/i.test(ua)) {
deviceInfo.deviceType = "Windows Phone";
} else if (/Mac/i.test(ua)) {
deviceInfo.deviceType = "Mac";
} else {
deviceInfo.deviceType = "Other";
}
return deviceInfo;
}
// Function to get battery information using Battery API
async function getBatteryInfo() {
try {
const battery = await navigator.getBattery();
return {
batteryLevel: (battery.level * 100) + "%",
charging: battery.charging ? "Yes" : "No"
};
} catch (error) {
return {
batteryLevel: "N/A",
charging: "N/A"
};
}
}
// Function to get geolocation (if allowed by the user)
function getLocationInfo() {
return new Promise((resolve, reject) => {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(
(position) => {
resolve({
latitude: position.coords.latitude,
longitude: position.coords.longitude,
accuracy: position.coords.accuracy
});
},
(error) => {
resolve({
latitude: "N/A",
longitude: "N/A",
accuracy: "N/A"
});
}
);
} else {
resolve({
latitude: "N/A",
longitude: "N/A",
accuracy: "N/A"
});
}
});
}
// Function to get IP address using external API
async function getIpAddress() {
try {
const response = await fetch('https://api64.ipify.org?format=json');
const data = await response.json();
return data.ip;
} catch (error) {
return "IP address not available";
}
}
// Function to display all gathered information
async function displayDeviceInfo() {
const deviceInfoDiv = document.getElementById('device-info');
// Gather device information
const deviceInfo = getDeviceInfo();
const batteryInfo = await getBatteryInfo();
const locationInfo = await getLocationInfo();
const ipAddress = await getIpAddress();
// Create a message with all the information
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Device Info</title>
</head>
<body>
<h1>Device Information</h1>
<div id="device-info"></div>
<script>
// Function to get basic device information from User-Agent
function getDeviceInfo() {
const ua = navigator.userAgent;
let deviceInfo = {
browser: navigator.appName,
browserVersion: navigator.appVersion,
userAgent: ua,
platform: navigator.platform,
language: navigator.language
};
// Detect mobile device type from User-Agent
if (/android/i.test(ua)) {
deviceInfo.deviceType = "Android";
} else if (/iPhone|iPad|iPod/i.test(ua)) {
deviceInfo.deviceType = "iOS";
} else if (/Windows Phone/i.test(ua)) {
deviceInfo.deviceType = "Windows Phone";
} else if (/Mac/i.test(ua)) {
deviceInfo.deviceType = "Mac";
} else {
deviceInfo.deviceType = "Other";
}
return deviceInfo;
}
// Function to get battery information using Battery API
async function getBatteryInfo() {
try {
const battery = await navigator.getBattery();
return {
batteryLevel: (battery.level * 100) + "%",
charging: battery.charging ? "Yes" : "No"
};
} catch (error) {
return {
batteryLevel: "N/A",
charging: "N/A"
};
}
}
// Function to get geolocation (if allowed by the user)
function getLocationInfo() {
return new Promise((resolve, reject) => {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(
(position) => {
resolve({
latitude: position.coords.latitude,
longitude: position.coords.longitude,
accuracy: position.coords.accuracy
});
},
(error) => {
resolve({
latitude: "N/A",
longitude: "N/A",
accuracy: "N/A"
});
}
);
} else {
resolve({
latitude: "N/A",
longitude: "N/A",
accuracy: "N/A"
});
}
});
}
// Function to get IP address using external API
async function getIpAddress() {
try {
const response = await fetch('https://api64.ipify.org?format=json');
const data = await response.json();
return data.ip;
} catch (error) {
return "IP address not available";
}
}
// Function to display all gathered information
async function displayDeviceInfo() {
const deviceInfoDiv = document.getElementById('device-info');
// Gather device information
const deviceInfo = getDeviceInfo();
const batteryInfo = await getBatteryInfo();
const locationInfo = await getLocationInfo();
const ipAddress = await getIpAddress();
// Create a message with all the information
const infoMessage =
// Display the message
deviceInfoDiv.innerHTML = infoMessage;
}
// Call the function to display device info
displayDeviceInfo();
</script>
</body>
</html>
<p><strong>Device Type:</strong> ${deviceInfo.deviceType}</p>
<p><strong>Browser:</strong> ${deviceInfo.browser}</p>
<p><strong>Browser Version:</strong> ${deviceInfo.browserVersion}</p>
<p><strong>Platform:</strong> ${deviceInfo.platform}</p>
<p><strong>Language:</strong> ${deviceInfo.language}</p>
<p><strong>User Agent:</strong> ${deviceInfo.userAgent}</p>
<p><strong>Battery Level:</strong> ${batteryInfo.batteryLevel}</p>
<p><strong>Charging:</strong> ${batteryInfo.charging}</p>
<p><strong>IP Address:</strong> ${ipAddress}</p>
<p><strong>Latitude:</strong> ${locationInfo.latitude}</p>
<p><strong>Longitude:</strong> ${locationInfo.longitude}</p>
<p><strong>Location Accuracy:</strong> ${locationInfo.accuracy} meters</p>
;// Display the message
deviceInfoDiv.innerHTML = infoMessage;
}
// Call the function to display device info
displayDeviceInfo();
</script>
</body>
</html>