1) In the below program everytime program is run different numbers are generated.
#include <stdio.h>
int main()
{
srand(time(NULL));
printf("%d\n", rand());
return 0;
}
2)
2) the output of this C code is to print an integer between 0-999 including 0 and 999.
#include <stdio.h>
#include <stdlib.h>
int main()
{
printf("%d\n", rand() % 1000);
return 0;
}
#include <stdio.h>
int main()
{
srand(time(NULL));
printf("%d\n", rand());
return 0;
}
2)
2) the output of this C code is to print an integer between 0-999 including 0 and 999.
#include <stdio.h>
#include <stdlib.h>
int main()
{
printf("%d\n", rand() % 1000);
return 0;
}
No comments:
Post a Comment