coding (1)
coding (1)
#include <stdio.h>
int main() {
int x = 5, y = 10;
printf("Before swapping: x = %d, y = %d\n", x, y);
swap(&x, &y);
printf("After swapping: x = %d, y = %d\n", x, y);
return 0;
}
27. WAP in c to find area of room using pointer
#include <stdio.h>
int main() {
float length, width, area;
return 0;
}
28. Find Largest element using pointer
#include <stdio.h>
int main() {
int n;
int arr[n];
int largest;
findLargest(arr, n, &largest);
return 0;
}
29. Find largest element in array using pointer
#include <stdio.h>
int main() {
int n, *ptr, largest;
int arr[n];
ptr = arr;
largest = *ptr;
for (int i = 1; i < n; i++) {
if (*(ptr + i) > largest) {
largest = *(ptr + i);
}
}
return 0;
}
30. WAP to input a number and display its multiplication
table using pointer
#include <stdio.h>
int main() {
int number;
displayTable(&number);
return 0;
}
31. Area of a Room Using Structure
#include <stdio.h>
typedef struct {
float length;
float width;
} Room;
int main() {
Room room;
float area;
calculateArea(&room, &area);
return 0;
}
32. Find Largest Element in Array Using Structure
#include <stdio.h>
typedef struct {
int *arr;
int size;
} Array;
int main() {
Array array;
int largest;
int arr[array.size];
array.arr = arr;
findLargest(&array, &largest);
return 0;
}
33. Find Largest Element in Array Using Pointer and
Structure
#include <stdio.h>
typedef struct {
int *arr;
int size;
} Array;
int main() {
Array array;
int largest;
int arr[array.size];
array.arr = arr;
findLargest(&array, &largest);
return 0;
}
34. Multiplication Table Using Structure
#include <stdio.h>
typedef struct {
int number;
} Table;
int main() {
Table t;
displayTable(&t);
return 0;
}
35.Largest Element and Multiplication Table in One
Program Using Structure
#include <stdio.h>
typedef struct {
int *arr;
int size;
} Array;
typedef struct {
int number;
} Table;
int main() {
Array array;
Table table;
int largest;
int arr[array.size];
array.arr = arr;
printf("Enter %d elements:\n", array.size);
for (int i = 0; i < array.size; i++) {
scanf("%d", &arr[i]);
}
findLargest(&array, &largest);
printf("The largest element is: %d\n", largest);
displayTable(&table);
return 0;
}
36. Write a program to create a file and store student
information (roll number, name, and marks). Then display
the contents of the file.
#include <stdio.h>
typedef struct {
int roll;
char name[50];
float marks;
} Student;
int main() {
FILE *file;
char filename[50];
Student s;
int n;
fclose(file);
return 0;
}
37. Write a program to copy the contents of one file to
another.
#include <stdio.h>
int main() {
FILE *source, *destination;
char srcFilename[50], destFilename[50], ch;
fclose(source);
fclose(destination);
int main() {
FILE *source, *destination;
char srcFilename[50], destFilename[50], ch;
fclose(source);
fclose(destination);
int main() {
FILE *file;
char filename[50], text[200], ch;
fclose(file);
fclose(file);
return 0;
}
39. Write a program to create a file and store employee
information (ID, name, and salary). Then display the
contents of the file.
#include <stdio.h>
typedef struct {
int id;
char name[50];
float salary;
} Employee;
int main() {
FILE *file;
char filename[50];
Employee emp;
int n;
fclose(file);
return 0;
}
40. Write a program to create a file and store vehicle
details (registration number, model name, and price).
Then display the contents of the file.
#include <stdio.h>
typedef struct {
char regNumber[20];
char modelName[50];
float price;
} Vehicle;
int main() {
FILE *file;
char filename[50];
Vehicle veh;
int n;
fclose(file);
return 0;
}
41. Write a PHP program to display the sum of the first 10
natural numbers.
<?php
$sum = 0;
echo "The sum of the first 10 natural numbers is: " . $sum;
?>
42. Write a PHP program to check whether a given
number is even or odd.
<?php
$number = 25;
if ($number % 2 == 0) {
echo $number . " is an even number.";
} else {
echo $number . " is an odd number.";
}
?>
43. Write a PHP program to find the factorial of a number.
<?php
$number = 5;
$factorial = 1;
if ($number > 0) {
echo "$number is positive.";
} elseif ($number < 0) {
echo "$number is negative.";
} else {
echo "$number is zero.";
}
?>
46. Find the largest of three numbers.
<html>
<head>
<title>Largest of Three Numbers</title>
</head>
<body>
<h2>Find the Largest of Three Numbers</h2>
<script>
let num1 = 10, num2 = 25, num3 = 15;
<!DOCTYPE html>
<html>
<head>
<title>Check Number</title>
</head>
<body>
<h2>Check if a Number is Positive, Negative, or Zero</h2>
<script>
let number = -5;
if (number > 0) {
document.write(`${number} is a positive number.`);
} else if (number < 0) {
document.write(`${number} is a negative number.`);
} else {
document.write(`${number} is zero.`);
}
</script>
</body>
</html>
50. Print the multiplication table of a number
<!DOCTYPE html>
<html>
<head>
<title>Multiplication Table</title>
</head>
<body>
<h2>Multiplication Table of a Number</h2>
<script>
let number = 5;
document.write(`<h3>Multiplication table of ${number}:</h3>`);
for (let i = 1; i <= 10; i++) {
document.write(`${number} x ${i} = ${number * i}<br>`);
}
</script>
</body>
</html>