Exercise-1
1. Write a C program that contains a string (char pointer) with a value \Hello World’. The program should XOR each character in this string with 0 and displays the result.
#include <stdio.h>
int main() {
const char *str = "Hello World";
int i = 0;
printf("Result after XOR with 0:\n");
while (str[i] != '\0') {
char result = str[i] ^ 0; // XOR with 0
printf("%c", result);
i++;
}
printf("\n"); // newline for neat output
return 0;
}
Sample Output:
Result after XOR with 0:
Hello World