Professional Documents
Culture Documents
HW 7
HW 7
( 1
:
double strToDouble(char str[]);
,
.(double-)
.2356.12- " -122356." ,
" ,"0" : .( ),
."145.63" ,"0.3-" ,"0.3
. -
. 100-
.stdlib.h
.
10.
;))num=num/(PowerOfTen(counter
;)return (num*sign
}
)(int main
{
;]char string[ARRAY_SIZE
;double result
;int i=0
(2
:
;)][int identify (char str
:
n ) n (1
k , ) k < n
, k- (
0 1- . .
:
:
:
:
:
:
:
:
1 :
aacd
1 :
aab
1 :
aaaabcc
0 :
aacdd
0 :
aabddd
0 :
aaccdd
0 :
aacc
. ) (,
' .
100 .
) -(.
:
:
cabc
aaacdd
ab
1ababababc
aaacdd
ab
* Assignment No: 7
* Question No: 2
#include <stdio.h>
#define FALSE 0
#define TRUE (!FALSE)
#define STR_LENGTH 100
int main()
/* Note: Assumes the user only inserts strings that fulfill the assignment's definition of a proper
string*/
{
char str[4][STR_LENGTH+1];
int i=0, check=TRUE;
printf("Please insert 4 valid strings:\n");
for (i=0; i<4; i++)
scanf("%100s", str[i]);
printf("The following strings are correct:\n");
//Prints the strings that fulfill the requirements:
for (i=0; i<4; i++)
if (identify(str[i]))
{
printf("%s\n", str[i]);
//Checks if there's at least one string that fulfills the requirement (FALSE
if fulfills):
check= FALSE;
}
if (check)
printf("NONE are correct!\n");
}
return 0;