-
Notifications
You must be signed in to change notification settings - Fork 0
/
function.c
60 lines (46 loc) · 1.13 KB
/
function.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <stdio.h>
void sum();
int multiplication();
void helloWorld();
char* GetUserName();
int main() {
int num1 = 2;
int num2 = 3;
// call sum function
sum( num1, num2 );
// call multiplication function.
int result = multiplication( num1, num2 );
printf("multiplication result is: %d\n", result);
// call hello world function
helloWorld();
// call get userName
/* const char* name = GetUserName();
printf("user name: %s",name); */
printf("\nuser name is: %s",GetUserName());
}
// sum function
void sum(int num1,int num2) {
int result = num1 + num2;
printf( "\naddition result is: %d\n", result);
}
// multiplication function
int multiplication( int num1, int num2 ) {
int result = num1 * num2;
return result;
}
// helloworld function
void helloWorld() {
printf("Hello world\n");
}
// getUserName function
// this function shows how to return a string?
// user * after keywerd char to return a string
char* GetUserName() {
char *name;
char name1[20];
printf("Enter username: ");
// input username
scanf("%s", name1);
name = name1;
return name;
}