-->

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;
}

No comments:

Post a Comment