//Exercise 2: Write a program that uses six calls to the function rand() to generate six random integer numbers, num1, num2, num3, num4, num5, and num6, and then print them out.
//num1 should be in the range 1 to 2 (inclusive), num2 should be in the range 1 to 100 (inclusive), num3 should be in the range 0 to 9, num4 should be in the range 1000 to 1112 (inclusive), num5 should be in the range -1 to 1, and num 6 should be in the range -3 to 11.
#include<stdio.h>
#include<stdlib.h>
#include<stdio.h>
void line()
{
int i;
printf("\n");
for(i=1;i<=43;i++)
printf("=");
}
void header()
{
printf("\n");
printf("Built and Designed by Arslan-ud-Din-Shafiq\n\nReg. No .DDP-SP14-BSE-005");
printf("\n");
}
int main()
{
int numbers,num1,num2,num3,num4,num5,num6;
line();
header();
line();
num1=rand()%2+1;
printf("\n%d\n",num1);
num2=rand()%100+1;
printf("%d\n",num2);
num3=rand()%10;
printf("%d\n",num3);
num4=rand()%113+1000;
printf("%d\n",num4);
num5=rand()%3-1;
printf("%d\n",num5);
num6=rand()%15-3;
printf("%d\n",num6);
return 0;
}
//num1 should be in the range 1 to 2 (inclusive), num2 should be in the range 1 to 100 (inclusive), num3 should be in the range 0 to 9, num4 should be in the range 1000 to 1112 (inclusive), num5 should be in the range -1 to 1, and num 6 should be in the range -3 to 11.
#include<stdio.h>
#include<stdlib.h>
#include<stdio.h>
void line()
{
int i;
printf("\n");
for(i=1;i<=43;i++)
printf("=");
}
void header()
{
printf("\n");
printf("Built and Designed by Arslan-ud-Din-Shafiq\n\nReg. No .DDP-SP14-BSE-005");
printf("\n");
}
int main()
{
int numbers,num1,num2,num3,num4,num5,num6;
line();
header();
line();
num1=rand()%2+1;
printf("\n%d\n",num1);
num2=rand()%100+1;
printf("%d\n",num2);
num3=rand()%10;
printf("%d\n",num3);
num4=rand()%113+1000;
printf("%d\n",num4);
num5=rand()%3-1;
printf("%d\n",num5);
num6=rand()%15-3;
printf("%d\n",num6);
return 0;
}
No comments:
Post a Comment