A

@Adarsh222

Union

C
3 years ago
#include <stdio.h> union example { int integer; float floating_point; char character; }; int main() { union example my_union;

indirect recursion

C
3 years ago
#include <stdio.h> int odd(); int num = 1; void even(){ if(num<=10) { printf("even no = %d\n", num-1); num++; odd();

REcursion

C
3 years ago
#include <stdio.h> void countDown(int n) { if (n <= 0) { printf("Countdown complete!\n"); } else { printf("%d\n", n); countDown(n - 1); // Recursive call } }

Unsigned and signed

C
3 years ago
#include <stdio.h> int main() { int signedInt = -10; unsigned int unsignedInt = 10;// or uint32_t printf("Signed int: %d\n", signedInt); printf("Unsigned int: %u\n", unsignedInt); unsignedInt = -10;

Difference between Priority Inversion and Priority Inheritance

C
3 years ago
In one line, Priority Inversion is a problem while Priority Inheritance is a solution. Priority Inversion means that the priority of tasks gets inverted and Priority Inheritance means that the priority of tasks gets inherited. Both of these phenomena happen in priority scheduling. Basically, in Priority Inversion, the higher priority task (H) ends up waiting for the middle priority task (M) In priority inversion, a higher-priority process is preempted by a lower-priority process. It is a met

RTOS SEMA VS MUTEX SIMPLE WORDS

C
3 years ago
In simple terms, a mutex and a semaphore are both mechanisms used to control access to shared resources in concurrent programs, but they differ in their usage and behavior. A mutex (short for "mutual exclusion") is a lock that allows only one thread to access a shared resource at a time. When a thread acquires a mutex lock, it gains exclusive access to the shared resource and blocks any other threads from accessing it until the lock is released. A semaphore, on the other hand, is a

CAllback uses and def

C
3 years ago
it notifies the main code when its done this gives more reuasability of code because the 1st function can be costomised without modifying the second function A callback function is a function that is passed as an argument to another function and is intended to be called by the other function at a certain point in time. When the callback function is called, it can perform a certain action or set of actions, depending on what it was designed to do.

Call Back ex in c

C
3 years ago
#include <stdio.h> #if 0 void print_hello() { printf("Hello, world!\n"); } void call_function(void (*function)()) { (*function)(); }

INLINE BASICS

C
3 years ago
In C programming language, the inline keyword is used to suggest the compiler to replace the function call with the function's code during the compilation process. This can improve the performance of the program by reducing the overhead of function call. Note that the inline keyword is only a suggestion to the compiler and it's up to the compiler to decide whether to inline the function or not. In addition, the function's code may still be included in the binary even if it's not inlined, so

Reverse linked list

C
3 years ago
#include<stdio.h> #include<stdlib.h> struct Node{ int data; struct Node *next; }; static int count = 0;

using *ptr diam array

C
3 years ago
#include <stdio.h> void change_values(int **p, int rows, int cols) { int i, j; int *ptr; for (i = 0; i < rows; i++) { for (j = 0; j < cols; j++) { ptr = *(p + i) + j; *ptr = i * j; (*ptr)++;

**p is a double pointer, which is a pointer to a pointer.

C
3 years ago
#include <stdio.h> #include <stdlib.h> int main() { int rows = 3, cols = 4; int i, j; int **p = (int **)malloc(rows * sizeof(int *)); // allocate memory for rows // allocate memory for columns for (i = 0; i < rows; i++) {

Typecasting Pointer

C
3 years ago
#include <stdio.h> int main() { int x = 42; int *p = &x; printf("The value of x is: %d\n", x); printf("The value of *p is: %d\n", *p); printf("The value of p is: %p\n", (void *)p); printf("The address of x is: %p\n", (void *)&x);

remove the particular integer from an array

C
3 years ago
#include <stdio.h> int main(){ int a[10] = {0}; int k=0; for(int i=0;i<6;i++){ scanf("%d",&a[i]); }

Program to remove the duplicate element in an array

C
3 years ago
#include <stdio.h> #include <string.h> int main() { int a[10] = {0}; int m = 0; for(int i=0;i<6;i++){ scanf("%d",&a[i]); }

sizeof()

C
3 years ago
#include <stdio.h> size_t sizeof_func(const void *ptr); int main() { int x = 10; size_t size = sizeof_func(&x); printf("The size of x is %zu bytes\n", size); return 0; }

strlen

C
3 years ago
#include <stdio.h> #define pointer //#define array size_t my_strlen(const char* str) { #ifdef pointer size_t length = 0; while (*str != '\0') { length++;

strcmp

C
3 years ago
#include <stdio.h> int strrcmp(char *str, char *sub){ while(*str!='\0'){ if(*str==*sub){ *str++; *sub++; } else{ return 1;

Strcpy

C
3 years ago
#include <stdio.h> char* strcpy(char* dest, const char* src) {//we use this to retun statements for str while (*src != '\0') {//we use * for dereferece pointer to char to copy char insted of address *dest = *src; dest++; src++; }

union ex

C
3 years ago
#include <stdio.h> #include <string.h> union data { int i; float f; char str[20];//largest is 20 }; int main() {