A

@Adarsh222

2darray

C
2 years ago
#include <stdio.h> /*0, 1, 2 //00 11 22 //02 11 20 3, 4, 5, 6, 7, 8 ==> 0, 2, 4, 6, 8*/ int main() { int n = 0; int m = 0;

array exception imp

C
2 years ago
#include <stdio.h> void out(int *a, int arr[], char *str, int sz){ printf("%d\n",*a); //in C, when you pass an array to a function, it decays into a pointer, and you lose the information //about its size. In this case, you won't be able

replace word with index manuplate

C
3 years ago
#include <stdio.h> #include <string.h> // Function to find the first occurrence of 'find' in 'str' // Returns the index of the first character of 'find' in 'str' // Returns -1 if 'find' is not found in 'str' int strstrr(char *str, char *find) {

replace word

C
3 years ago
#include <stdio.h> #include <string.h> int main() { char input_string[] = "my name adarsh"; char search[] = "name"; char replace[] = "was"; // Find the index of the first occurrence of "name" char *found = strstr(input_string,

strstr

C
3 years ago
#include <stdio.h> int strstr_custom(const char *haystack, const char *needle) { int index = 0; const char *n = needle; while (*haystack) { const char *h = haystack;//imp Reset the pointers to the current position in the st

typedef struct

C
3 years ago
#include <stdio.h> typedef struct{ int num; } data; int main() { data d1; d1.num=6; printf("%d",d1.num);

Check how many palindrome words are there

C
3 years ago
#include <stdio.h> #include <string.h> int isPalindrome(const char *str, int start, int end) { while (start < end) { if (str[start] != str[end]) { return 0; // Not a palindrome } start++; end

switch

C
3 years ago
The provided code snippet contains a switch statement with a syntax error. The printf("hello"); line is outside the switch block, and it will cause a compilation error. int a = 2; switch (a) { printf("hello");//remember ouside of case se cannot a

Write your version of memcopy. They would generally write it to make the copy using char, check if t

C
3 years ago
#include <stdio.h> void* my_memcpy(void* dest, const void* src, size_t n) { char* dest_ptr = (char*)dest; const char* src_ptr = (const char*)src; for (size_t i = 0; i < n; i++) { dest_ptr[i] = src_ptr[i]; }

Append and delete the nth node imp

C
3 years ago
#include <stdio.h> #include <stdlib.h> // Define the structure for the linked list node struct Node { int data; struct Node* next; }; // Function to print the linked list

Hex imp code

C
3 years ago
/*Write a C program that takes a hexadecimal number and an integer 'pos' as input. Set 'pos' number of bits from the right to 1 in the given hexadecimal number and print the modified hexadecimal number as the output.*/ #include <stdio.h> int set_a

Dynamic Memory Allocation and Pointer Usage in C Programming

C
3 years ago
#include <stdio.h> int main() { int* address = (int*)0x12345678; // Replace 0x12345678 with the desired memory address // Write data to the memory address directly *address = 123; // Verify the written data by reading it back usin

Struct use in one file to other

C
3 years ago
#include <stdio.h> #include <stdlib.h> #include <string.h> struct Person {//can be written in header file char name[50]; int no; }; void print(struct Person person) {//can be written in header file

Getter setter ex in c

C
3 years ago
#include <stdio.h> //we can name anything for set and get funs since its basic fn not any defined // Private variable static int age; // Getter function int getAge() {// it just return the static value in this file return age;//can can be ac

Getter and Setter functions

C
3 years ago
In C, getter and setter functions are used to provide controlled access to variables. They are a way to read and modify the values of variables indirectly, rather than directly accessing them. Here's a simple explanation of getter and setter fun

How can we use a static variable from one file to another

C
3 years ago
No, a static variable defined within a file (also known as file-scope static variable) cannot be accessed directly from another file. The static keyword in C restricts the scope of a variable to the current file only. However, if you need to a

Canvert and modify the value

C
3 years ago
#include <stdio.h> int main() { int hex = 0x10;//0001 0000 int dec = hex;//16 = 10000 binary //1<<2 -> 0000 0001 -> 0000 0100 dec = dec^(1<<4);// 1<<4 means 0001 0000 then 0001 0000 ^ 0001 0000?

IMP To convert hexadecimal to decimal and the modify bits

C
3 years ago
/*Note:- we can modify the or use bitwase operation only on decimal/binary numbers so idf we want to change any bit we can do it in only decimal/binary no so we 1st need to convers hex to decimal/binary and then modify*/

Str and Int in one linkedlist

C
3 years ago
#include <stdio.h> #include <stdlib.h> #include <string.h> struct node { int data; char a[10]; struct node* next; };

combine 2 1byte data type into 2byte data type

C
3 years ago
#include <stdio.h> unsigned char a = 0x10;//0001 0000 unsigned char b = 0x20;//0010 0000 int main() { unsigned short data = 0; data = (unsigned short)(a << 8) + b;//binary: 0001 0000 0000 0000 //data = data | b;//0x1020 binary: 0001 0