ahmed0saber

Pick random 3-characters string in C++

Nov 5th, 2020
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.25 KB | None | 0 0
  1. #include<iostream>
  2. #include<stdlib.h>
  3. using namespace std;
  4. char intToAlphabet( int i )
  5. {
  6.    return static_cast<char>('A' - 1 + i);
  7. }
  8. int main()
  9. {
  10.     int n=0 , x;
  11.     while(n<3)
  12.     {
  13.         x=rand() % 26 + 1;
  14.         cout<<intToAlphabet(x);
  15.         n=n+1;
  16.     }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment