Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
2 views3 pages

Practical Assignment No 1-Is

The document outlines a practical assignment to write a C program that manipulates the string 'Hello World' using bitwise operations (AND, OR, XOR) with the value 127. It includes the program code, expected output, and a conclusion explaining the results of the operations. The assignment requires an Intel-based PC with 4GB RAM and TurboC/Borland C software.

Uploaded by

nrasika1122
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views3 pages

Practical Assignment No 1-Is

The document outlines a practical assignment to write a C program that manipulates the string 'Hello World' using bitwise operations (AND, OR, XOR) with the value 127. It includes the program code, expected output, and a conclusion explaining the results of the operations. The assignment requires an Intel-based PC with 4GB RAM and TurboC/Borland C software.

Uploaded by

nrasika1122
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Practical Assignment No.

Title:

Write a C program that contains a string (char pointer) with a value \Hello World’. The
program should AND or and XOR each character in this string with 127 and display the result.

Aim:

Write a C program that contains a string (char pointer) with a value \Hello World’. The
program should AND or and XOR each character in this string with 127 and display the result.

Hardaware and Software Requirement:

Intel Based Desktop PC: RAM 4GB

TurboC/Borland C
Program:

#include<conio.h>
#include <stdio.h>
#include<stdlib.h>
void main(){
char str[]="Hello World";
int i,len;
len = strlen(str);
for(i=0;i<len;i++){
printf("%c",str[i]&127);
}
printf("\n");
for(i=0;i<len;i++){
printf("%c",str[i]^127);
}
printf("\n");
for(i=0;i<len;i++){
printf("%c",str[i]|127);
}
printf("\n");
getch();
}

Output:

Conclusion:
It is expected to see "garbage" with OR or XOR. Your string Hello World is pure
ASCII, so it consists of characters with encoding values less than 127. A bitwise AND
with 127 does not change the value, so you will see Hello World.

You might also like