Codes c1? ?
Codes c1? ?
#include <stdio.h>
int main() {
int arr[] = {10, 2, 8, 5, 17};
int n = sizeof(arr) / sizeof(arr[0]);
int target = 8;
int result = linearSearch(arr, n, target);
if (result == -1) {
printf("Element not found in the array.\n");
} else {
printf("Element found at index: %d\n", result);
}
return 0;
}
#include <stdio.h>
int main() {
int myArray[] = {1, 3, 5, 7, 9, 11, 13, 15, 17, 19};
int myTarget = 15;
int size = sizeof(myArray) / sizeof(myArray[0]);
if (result != -1) {
printf("Value %d found at index %d\n", myTarget, result);
} else {
printf("Target not found in array.\n");
}
return 0;
}
if (arr[mid] == targetVal) {
return mid;
}
return -1;
}
#include <stdio.h>
#include <string.h>
// declaring structure
struct struct_example {
int integer;
float decimal;
char name[20];
};
// declaring union
union union_example {
int integer;
float decimal;
char name[20];
};
void main()
{
// creating variable for structure
// and initializing values difference
// six
struct struct_example s = { 18, 38, "geeksforgeeks" };
// difference five
printf("\n Accessing all members at a time:");
s.integer = 183;
s.decimal = 90;
strcpy(s.name, "geeksforgeeks");
u.integer = 183;
u.decimal = 90;
strcpy(u.name, "geeksforgeeks");
printf("\nstructure data:");
s.integer = 240;
printf("\ninteger: %d", s.integer);
s.decimal = 120;
printf("\ndecimal: %f", s.decimal);
u.decimal = 120;
printf("\ndecimal: %f", u.decimal);
// difference four
printf("\nAltering a member value:\n");
s.integer = 1218;
printf("structure data:\n integer: %d\n "
" decimal: %.2f\n name: %s\n",
s.integer, s.decimal, s.name);
u.integer = 1218;
printf("union data:\n integer: %d\n"
" decimal: %.2f\n name: %s\n",
u.integer, u.decimal, u.name);
}
#include <stdio.h>
int main()
{
// Declare and initialize a character array
char str[] = "Hello, world!";
int length;
return 0;
}
#include <stdio.h>
int main() {
int arr[] = { 6, 0, 3, 5 };
int n = sizeof(arr) / sizeof(arr[0]);
return 0;
}
WAP to Open a File, Write in it, And Close the File // File Handling
#include <stdio.h>
#include <string.h>
int main()
{
return 0;
}