sharing balance

hello, i m a newbie in c++..i nid u all to help me..how to share the new_balance with void call() and void sms()?

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
#include<stdio.h>
void sms();
void call();
void topup();
void logo();
 
void main()
{
logo();
}
 
void logo()
{
printf("[1] Call, [2] SMS, [3] TOP UP, [4] EXIT ? ");
    scanf("%d", &choose);
    if(choose == 1)
    {
    printf("\nYou Have Choosen %s\n", "CALL");
    call();
    }
    else
    {
    }
    if(choose == 2)
    {
    printf("\nYou Have Choosen %s\n", "SMS");
    sms();
    }
    else
    {
    }
    if(choose == 3)
    {
    printf("\nYou Have Choosen %s\n", "TOP UP");
    topup();
    }
    else
    {
    }
    if(choose == 4)
    {
    printf("\nYou Have Choosen %s\n", "EXIT");
    logo();
    }
    else
    {
    }
}
void call()
{
double balance = 10.0, call_duration, new_balance;
printf("The Prepaid Balance = %.2lf\n", balance);
printf("Call Duration(minutes) : ");
scanf("%f", &call_duration);
new_balance = balance - (call_duration * 0.50);
printf("Your new balance = %.2lf", new_balance);
}
void sms()
printf("The Prepaid Balance = %.2lf\n", new_balance);
Last edited on
new_balance seems to be calculate by call, so simply have the function return the value. Then have the sms function take the value as an argument.
Topic archived. No new replies allowed.