Help with functions assignment

On line 28, I keep getting an error message saying "uninitialized variable b and c" What am I doing wrong??? I initialized a, b, and c, but only a is getting accepted for some reason...

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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
  // Lab_3_cpp : Defines the entry point for the console application.
//Name: 
//Student ID: 
//Section: 
//
//

#include "stdafx.h"
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <cmath>
#include <stdlib.h>

using namespace std;

int Sambix(int, int, int);

int _tmain(int argc, _TCHAR* argv[])
{
	int a;
	int b;
	int c;

	cout << "Please enter three integer values" << endl;
	cin >> a, b, c;

	cout << Sambix(a, b, c) << endl;
	
	system("pause");
	return 0;
}

int Sambix(int a, int b, int c)
{
	if (abs(a) < abs(b) && abs(c) || abs(a) < abs(c) && abs(b))
	{
		cout << a << endl;
	}
	else if (abs(b) < abs(a) && abs(c) || abs(b) < abs(c) && abs(a))
	{
		cout << b << endl;
	}
	else (abs(c) < abs(a) && abs(b) || abs(c) < abs(b) && abs(a));
	{
		cout << c << endl;
	}
	if (abs(c) == abs(a) == abs(b))
	{
		cout << c << endl;
	}
	else {};
	if (abs(a) == abs(b) < abs(c))
	{
		cout << a << endl;
	}
	else {};
	if (abs(a) == abs(c) < abs(b))
	{
		cout << a << endl;
	}
	else {};
	if (abs(b) == abs(a) < abs(c))
	{
		cout << b << endl;
	}
	else {};
	if (abs(b) == abs(c) < abs(a))
	{
		cout << b << endl;
	}
	else {};
	if (abs(c) == abs(a) < abs(b))
	{
		cout << c << endl;
	}
	else {};
	if (abs(c) == abs(b) < abs(a))
	{
		cout << c << endl;
	}
	else {};
	if (a, b, c == 0)
	{
		cout << "Program will now terminate" << endl;
		return 0;
	}
	else {};

	system("pause");
	return 0;
}
Last edited on
Line 26
 
    cin >> a, b, c;


should read
 
    cin >> a >> b >> c;


The comma operator has rather specialised uses, its use is often misunderstood.
http://www.cplusplus.com/doc/tutorial/operators/

I initialized a, b, and c

No, you didn't.
21
22
23
	int a;
	int b;
	int c;

There is no initial value given here.
Last edited on
Topic archived. No new replies allowed.