Help me out please

Hello
I'm new to c++ and relatively new to programming
i need to write a program that displays either a random number or a random letter
here is my code

#include <iostream>
#include <windows.h>
#include <fstream>
using namespace std;
int main()
{
int y = rand () % 3 + 1;
int n = rand() % 26;
char c = (char)(n+65);
srand ( time(NULL) );
{
if ( y=1 )
{cout << rand() % 10 + 0;}
else
{cout << c << endl;}
}
}

whem i compile it only displays a random number... where did i go wrong
... oh and sorry for my formating
You have to remember that all of the "numbers" you see have ASCII representations as characters so simply casting a number to a character could potentially display a number. Here's a link to a copy of the ASCII chart: http://www.asciitable.com/
as it turns out my problem was that instead of y==1 i wrote y=1 but thanks for the advice i guess here is my final code

#include <windows.h>
#include <fstream>
#include <iostream>
using namespace std;
int main()
{
ofstream myfile;
myfile.open ("Gen.txt");
{
for (int n=0; n<50; n++)
{
srand ( GetTickCount() );
int a = rand() % 26 + 0;
srand ( GetTickCount() );
char b = (char)(a+65);
srand ( GetTickCount() );
int c = rand() % 10 + 0;
srand ( GetTickCount() );
int d = rand () % 3 + 1;
{
if ( d==1 ) {myfile << c; cout << c;}
else {myfile << b; cout << b;}
Sleep (20);
}
}
}
}
Topic archived. No new replies allowed.