I know its easy but its been a long week of test. I have been working with a program to enter 5 integers( 1 2 3 4 5 ) then in its output it will display those same 5 integers. Then next to the last number it will encrypted the input and and output so that 1 is added to the last number the 4th and 3rd are switched and the 1st and second are switched. I can output the five numbers but I am have problems with the encrypting. Thank you for your help.

Please post what you've tried...start out with a pen & paper! Write out an algorithm....which part of the assignment are you stuck?

This is what I have so far. I can get the easy part of displaying the same 5 digits but
not only has my teacher never gone over something like this I have never played around with something like this.

#include <iostream> 
#include <iomanip>

int main()
{
	// a , b , c , d , e are the digits of plaintext
	int a = 0, b = 0, c = 0 , d = 0 , e = 0;
	
	//int a1 = 0, b1 = 0, c1 = 0 , d1 = 0 , e1 = 0;
	 

	std::cout << "Enter a 5 digit number"; 
	std::cin >> a , b , c , d , e;
	std::cout << a , b , c , d , e;

// a1 , b1 , c1 , d1 , e1 are the digits of the encrypted ciphertext

That's not how you input and output numbers.

Separate variables in a stream with << or >> (not commas) depending on whether you're working with an input or output stream. You'll probably also want to separate them with spaces when outputting so that it doesn't all come out as one huge number.

I do like that alot better than what I am being told to do in this paper. I am sure it wouldn't matter how it was outputted.

As for your encryption (once you've fixed your I/O issues), I'll give you a hint: to swap variables, you need a third 'temp' variable. E.g.

int variable1 = 2;
int variable2 = 3;
int swap;

swap = variable1;
variable2 = variable1;
variable1 = swap;

There you go. You've got your work cut out for you.

i think it would b better if you take them in an array ...
for swap i would suggest you use the XOR (^) operator to do it without a temp..

I still have not learn that yet. This is my first time programming. I am just having some problems with picking up the early stuff. What was your method of learning when you began? I go over and over notes and try things but sometimes when i get assignments i just draw blanks for ideas on how to solve them.

method of learning i use is to take up a book and start with the basics.. try simple programs for the each topics and then move ahead.. dont rush, dont expect to learn everything in a day and dont try and jump to complex topics without learing the basics .. you can forget about the XOR and array for now and implement the swap method suggested by joeprogrammer.. also writing down the algorithm before starting really helps..

method of learning i use is to take up a book and start with the basics.. try simple programs for the each topics and then move ahead..

Nice idea -- if you are learning on your own. When you are taking a class you must follow the instructor.

This article has been dead for over six months. Start a new discussion instead.