C++ noob scripts so far

Questions about programming languages and debugging
User avatar
hpprinter100
Fame ! Where are the chicks?!
Fame ! Where are the chicks?!
Posts: 214
Joined: 19 Oct 2007, 16:00
16
Contact:

Re: C++ noob scripts so far

Post by hpprinter100 »

I got lazy and havnt been doing any C++ for awhile, am going to get back into it now, just did this this morning.

Write a program that takes a series of numbers and counts the number of positive
and negative values.

Code: Select all

#include <windows.h>
#include <iostream>

using namespace std;

int main(){
int negative;
int posative;
int input; //number to check
negative = 0;
posative = 0;
	while(1){

cout << "Negatives " << negative << " Posatives " << posative << '\n';
cout << "Enter Number: ";
cin >> input; 
if (input <0)
	negative++;
else if (input == 0)
	cout << "0 is neither posative nor negative " << '\n';
else 
	posative++;
	}
return (0);
}

User avatar
Gogeta70
^_^
^_^
Posts: 3275
Joined: 25 Jun 2005, 16:00
18

Re: C++ noob scripts so far

Post by Gogeta70 »

Hpprinter100, i suggest making more useful programs now if you want to get any better at C++. Maybe make a program that encrypts a file using a simple algorithm, like ROT128 or something. It'll help you learn a lot faster.

I suggest ROT128 because the encryption/decryption methods are the same. Actually, i think ROT128 is more of an encoding/decoding procedure, since it doesn't require a key or anything to decrypt. But well, you get my point.
¯\_(ツ)_/¯ It works on my machine...

Post Reply