Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
ilahma
/
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
8fff08e2
authored
6 years ago
by
ilahma
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
fbe52946
master
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
74 additions
and
0 deletions
switch.c
switch.c
0 → 100644
View file @
8fff08e2
#include <stdio.h>
int
add
(
int
a
,
int
b
);
int
subtract
(
int
a
,
int
b
);
int
multiplication
(
int
a
,
int
b
);
int
division
(
int
a
,
int
b
);
int
main
()
{
int
a
;
int
b
;
char
operator
;
printf
(
"Enter two numbers:
\n
"
);
scanf
(
"%d %d"
,
&
a
,
&
b
);
printf
(
"Please, enter an operator: +,-,*,:
\n
"
);
scanf
(
" %c"
,
&
operator
);
switch
(
operator
)
{
case
'+'
:
printf
(
"%d + %d = %d"
,
a
,
b
,
add
(
a
,
b
));
break
;
case
'-'
:
printf
(
"%d - %d = %d"
,
a
,
b
,
subtract
(
a
,
b
));
break
;
case
'*'
:
printf
(
"%d * %d = %d"
,
a
,
b
,
multiplication
(
a
,
b
));
break
;
case
'/'
:
printf
(
"%d / %d = %d"
,
a
,
b
,
division
(
a
,
b
));
break
;
default:
printf
(
"Operator is not correct"
);
}
return
0
;
}
int
add
(
int
a
,
int
b
)
{
return
a
+
b
;
}
int
subtract
(
int
a
,
int
b
)
{
return
a
-
b
;
}
int
multiplication
(
int
a
,
int
b
)
{
return
a
*
b
;
}
int
division
(
int
a
,
int
b
)
{
return
a
/
b
;
}
This diff is collapsed.
Click to expand it.
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