-->
Showing posts with label program to generate random numbers. to understand rand() function. Show all posts
Showing posts with label program to generate random numbers. to understand rand() function. Show all posts

program to generate random numbers

using codeblocks
---------------------------------------------------------------------------------------------
//progrm to generate random numbers
#include <stdio.h>
#include <stdlib.h>  //contains rand() function
int main()
{
    int k,number;
    printf("how many u want=\n");
    scanf("%d",&number);
    printf("some randomly generated numbers are given below.\n");
    for(k=0;k<=number;k++)
    {
        printf("%7d\t",rand());//prints randomly generated numbers
    }
    return 0;
}
----------------------------------------------------------------------------------------------
using turboc++
--------------------------------------------------------------------------------------------------------
//progrm to generate random numbers
#include <stdio.h>
#include <stdlib.h>  //contains rand() function
#include<conio.h>
int main()
{
    int k,number;
    printf("how many u want=\n");
    scanf("%d",&number);
    printf("some randomly generated numbers are given below.\n");
    for(k=0;k<=number;k++)
    {
        printf("%7d\t",rand());//prints randomly generated numbers
    }
    getch();
    return 0;
}