Object
Write a program that prints 10 random numbers between 1 and 100.
Algorithm
- Declare integer variable i.
- Repeat FOR i = 0 to 9 by 1
- Write rand()%100 on screen.
- [End of FOR loop.]
- Exit.
Flowchart

C++ Source Code
// program 71
#include<iostream>
#include <iomanip>
using namespace std;
int main()
{
int i;
for (i = 0; i < 10; i++)
{
cout << setw(5) << rand() % 100; // in the range 0 to 99
}
return 0;
}
C Source Code
/*program 71*/
#include<stdio.h>
#include<stdlib.h>
int main()
{
int i;
for(i=0; i<10; i++)
printf("%5d", rand()%100);
return 0;
}
Output
41 67 34 0 69 24 78 58 62 64
