Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
viakul
/
iax0583
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
b6d171c3
authored
Nov 05, 2018
by
viakul
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update 4thtask.c
parent
f895dd08
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
38 deletions
Lab9/4thtask.c
Lab9/4thtask.c
View file @
b6d171c3
#include <stdio.h>
#include <stdio.h>
#include <string.h>
#include <string.h>
#include <stdlib.h>
#include <stdlib.h>
int
isInt
(
char
*
x
,
int
y
);
int
isInt
(
char
*
x
,
int
y
);
int
moreInt
(
char
*
x
,
int
y
,
int
i
);
int
moreInt
(
char
*
x
,
int
y
,
int
i
);
int
DeciConv
(
char
x
,
int
y
)
;
int
main
()
int
main
()
{
{
...
@@ -24,7 +22,7 @@ int main()
...
@@ -24,7 +22,7 @@ int main()
p
rintf
(
"Decimal equivalent of %s in base %d is %d
\n
"
,
x
,
y
,
DeciConv
(
x
,
y
));
p
uts
(
"this is the right input"
);
printf
(
"%s"
,
line
);
printf
(
"%s"
,
line
);
return
0
;
return
0
;
}
}
...
@@ -83,38 +81,4 @@ int isInt(char* x,int y){
...
@@ -83,38 +81,4 @@ int isInt(char* x,int y){
}
}
return
(
bool
);
return
(
bool
);
}
}
\ No newline at end of file
int
DeciConv
(
char
x
,
int
y
)
{
int
len
=
strlen
(
x
);
int
power
=
1
;
int
num
=
0
;
int
i
;
for
(
i
=
len
-
1
;
i
>=
0
;
i
--
)
{
if
(
val
(
x
[
i
])
>=
y
)
{
printf
(
"Invalid Number"
);
return
-
1
;
}
num
+=
val
(
x
[
i
])
*
power
;
power
=
power
*
base
;
}
return
num
;
}
int
val
(
char
c
)
{
if
(
c
>=
'0'
&&
c
<=
'9'
){
return
(
int
)
c
-
'0'
;
}
else
{
return
(
int
)
c
-
'A'
+
10
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment