square root - Sravani - Hari(testing)
string comparison ==> match ==> 0, not match ==> first mismatch character ASCII value difference (non-zero) - Hari - Rajini(Testing)
distance between two points. - Rajini-Sravini(Testing)
sqrt( (x2-x1)^2 + (y2-y1)^2)
Addition of two integers - Eswar
4 ==> 2*2
0.01*0.1 ==> 4
0.2*0.2 ==> 4
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1.0
1.1
1.2
1.3
1.4
1.5
1.6
1.7
1.8
1.9
2.0 ==> 2.0*2.0 ==> 4
9 ==> 3*3
Sravani:
HLR: Software shall have capability to calculate square root of a number.
LLR: The function square_root() shall calculate and return square root of n with given tolerance as per below algorithm
Architecture:
Library name: my_lib
Function name: square_root
inputs:
n (double)
tolerance (double)
outputs:
return value (double)
Purpose: Calculation of square root of a number.
Source Code:
my_lib.c:
double square_root (double n, double tolerance)
{
double s;
for(s=tolerance; s*s<n; s=s+tolerance)
{
;
}
return s;
}
my_lib.h:
extern double square_root (double n, double tolerance);
Eswar:
HLR: Software shall have capability to calculate addition of two integers.
LLR: The function addition() shall add and return num1 and num2.
Arch:
Library name: my_lib
Function name: addition
inputs:
num1 (32 bit int)
num2 (32 bit int)
outputs:
return value (64 bit int)
purpose: add and return two integers.
Source Code:
my_lib.c:
long int addition (int num1, int num2)
{
return num1+num2;
}
my_lib.h:
extern long int addition (int num1, int num2);
Rajini:
my_lib.c
double square_root (double n, double tolerance)
{
double s;
for(s=tolerance; s*s<n; s=s+tolerance)
{
;
}
return s;
}
double distance(double x1, double y1, double x2, double y2)
{
return square_root(((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1)), 0.0001);
}
my_lib.h:
extern double square_root (double n, double tolerance);
extern double distance(double x1, double y1, double x2, double y2);
#include <stdio.h>
int string_comparison (char *str1, char *str2);
int main()
{
printf("diff = %d\n", string_comparison("Harini", "Hari"));
return 0;
}
int string_comparison (char *str1, char *str2)
{
int d;
int i=0;
while(str1[i]!='\0' && str2[i] != '\0' && str1[i] == str2[i])
{
i++;
}
if(str1[i]=='\0' && str2[i]=='\0')
{
d=0;
}
else
{
d = (int)(str1[i] - str2[i]);
}
return d;
}