Search This Blog

Loading...

Implementation Of Checksum C Program

Algorithm Steps:
Step 1: Include the header file.
Step 2: Get two hexadecimal value from user in one and two.
Step 3: Add one and two and share the result in check.
Step 4: Find complement of the check and display its value.
Step 5: Find the complement of check result and display it.
Step 6: If the check of check result is 0 then print the checksum of code generated is correct.
Step 7: Else print the checksum of code generate is not correct.
Step 8: stop the program.
#include<stdio.h>
#include<stdlib.h>
#include<fentl.h>
int main()
{
unsigned int one;
unsigned int two;
unsigned int check;
unsigned int checkresult;

printf("\nEnter the first hex value:");
scanf("%x",&one);

printf("\nEnter the second hex value:");
scanf("%x",&one);

check=one+two;
check=check;

printf("\nThe value of check is:%x",check);
checkresult=one+two+check;

printf("\The value of checkresult:%x",checkresult);
checkresult=checkresult;
printf("\n The value of answer is :%x",check result);
else
printf("\n The check sum of the code generated is not correct");
}
OUTPUT:
[cseb56@localhost cseb56]$ cc che10.c
[cseb56@localhost cseb56]$./a.out
Enter the first hex value : 12345678
Enter the second hex value : 87654321
The value of check is : 66666666
The value of checkresult is : ffffffff
The value of answer is : 0
the check sum of the code generated is correct

No comments:

Post a Comment