A

@Adarsh222

imp bit shifting

C
3 years ago
#include <stdio.h> int main() { int num = 10; int shift_positions = 2; // Left shift operator int left_shifted = num << shift_positions; printf("Left shifted result: %d\n", left_shifted);

imp bit masking

C
3 years ago
#include <stdio.h> int main() { int num = 10; int mask = 7; // Turn on the 3rd and 1st bits num = num | (1 << 2); num = num | (1 << 0);

imp bitwise operations to set, clear, and toggle bits in an integer

C
3 years ago
#include <stdio.h> int main() { int num = 10; printf("Original number: %d\n", num); // Set the 3rd bit num = num | (1 << 2); printf("After setting the 3rd bit: %d\n", num);

imp Bitwise and logical diff

C
3 years ago
Bitwise and logical operators are used to perform operations on individual bits in a number. The difference between bitwise and logical operators is that logical operators perform operations on the entire number, whereas bitwise operators perform operations on individual bits. Logical operators are typically used to perform operations on boolean values, such as true and false, whereas bitwise operators are used to perform operations on binary representations of numbers. The followin

imp BIT basice

C
3 years ago
#include <stdio.h> int main() { int x = 5, y = 3; int result; result = x & y; printf("%d & %d = %d\n", x, y, result); result = x | y;

struct input and output

C
3 years ago
#include <stdio.h> #include <string.h> struct obj{ int a; int b; char c[10]; }; void print(struct obj one){

reverse the char in sentence

C
3 years ago
#include <stdio.h> int main() { char a[20]; int i; for (i = 0; i < 10 && scanf("%c", &a[i]) != EOF; i++); for (; i >= 0; i--) { printf("%c", a[i]);

Write a program to find the maximum contiguous subarray sum in an array of integers

C
3 years ago
#include <stdio.h> int conq_sum(int arr[], int size){ int max_sum = 0, curr_sum = 0; for(int i=0;i<size;i++){ curr_sum = curr_sum + arr[i]; //if(curr_sum > max_sum){ or can be use //max_sum = curr_sum;

enum basicss**

C
3 years ago
#include <stdio.h> enum check{ variable1 = 0, variable2 = 3, variable3 = 5 }; /*or enum{ aaa;

void

C
3 years ago
In C programming, "void" is a keyword used to indicate that a function or a pointer does not return a value. It can also be used as a placeholder for a data type when no value is needed or expected. For example, the main() function in a C program typically has a "void" return type, because it does not return a value to the operating system: Copy code int main(void) { // code here

pointer basics..

C
3 years ago
#include<stdio.h> #include<string.h> int add(int *var1,int *var2){ int sum; sum=*var1+*var2; return sum; } void stradd(char *string1,char *string2, char *str){

Exception Definition

C
3 years ago
Exception handling is a mechanism in computer programming to handle exceptional conditions, which are run-time errors that occur during the execution of a program. These errors are typically caused by conditions that are not anticipated by the programmer and can include things like division by zero, invalid memory access, and file not found errors. When an exception is thrown, the normal flow of control in the program is interrupted and the program jumps to a specific location where the

exception handling

C
3 years ago
C does not have built-in exception handling like some higher-level languages. Instead, it uses error codes or return values to indicate if an error occurred In C, error handling is typically done by returning error codes or values from functions. This is in contrast to languages with built-in exception handling, where exceptions are used to indicate and handle errors. When a function encounters an error, it can return a specific value or code indicating that an error occurred. The ca

struct imp use program

C
3 years ago
#include <stdio.h> #include <string.h> #if 0 struct operations { int a; int b[5]; char c[10]; };

Boolian

C
3 years ago
The bool type is used in C to represent boolean values, that is, true or false. It is particularly useful in situations where you need to store or manipulate boolean data, or when you need to perform a simple true/false test in your program. Some common uses of the bool type in C include: Control flow: You can use bool variables as conditions in control statements such as if, while, and for to control the flow of your program. For example: bool isPartitionEncyptFormatted()

professnal array

C
3 years ago
#include <stdio.h> #include <stdint.h> #include <stddef.h> int32_t ad(int32_t *arr,size_t size){ for(int32_t i=0;i<size;i++){ printf("%d",arr[i]); } }

break vs continue

C
3 years ago
#include <stdio.h> int main() { int i; // use a break statement to exit a for loop for (i = 0; i < 10; i++) { if (i == 5) { break; }

while vs do while

C
3 years ago
#include <stdio.h> int main() { int i = 0; // while loop while (i < 5) { printf("i = %d\n", i); i++; }

Professnal swap integers

C
3 years ago
#include <stdio.h> #include <stdint.h> #include <stddef.h>//size_t int32_t swap_variables(int32_t *var_1, int32_t *var_2){ int32_t var_temp; var_temp=*var_1; *var_1=*var_2; *var_2=var_temp;

string to integer

C
3 years ago
#include <stdio.h> #include <stdlib.h> int main() { // Convert the string "123" to an integer int i = atoi("adar"); // Print the integer value printf("%d\n", i);