The programs you've written above are pretty much what you'd expect from a beginner. As you continue to learn you'll have a more intimate understanding of what makes sense (in terms of program flow, structure and design, etc.), and you'll be able to consolidate and optimize your programs further and further.
Some more specific comments:
I see you ending your applications like so:
I'd like to suggest this instead:
1 2
|
std::cin.sync();
std::cin.get();
|
Additionally, I suggest that you remove the
using namespace std;
statement from the global scope. The only reason for using a
using
statement in your case is to be lazy, and because you're new you're not allowed to be lazy ;)
If you absolutely need to use it, put it in the most localized scope.
Also, you've got functions which look like this:
1 2 3 4 5 6 7
|
float v1()
{
cout << "Enter first number: ";
float val1;
cin >> val1;
return val1;
}
|
1 2 3 4 5 6 7
|
float v2()
{
cout << "Enter second number: ";
float val2;
cin >> val2;
return val2;
}
|
That seems very redundant. Why not write one function which you can use to pass any number as a reference? Why do you even need a function for that?
Also, I see this amongst your #includes:
#include "stdafx.h"
Perhaps you intentionally created your project with a precompiled header (I also don't know what IDE you're using, so it might be standard or something), but usually non-empty projects tend to introduce problems for beginners. There's nothing wrong with it, but it's not helping you, I think.
Also, think about giving your variables more appropriate names. I try to not use numbers in identifier names unless I would otherwise die, and it's pretty much standard to limit all-caps identifiers to #definitions or enums.
Also avoid goto statements and use loops instead.
Sorry, this sounds like a lecture. Just observations.