What would be the result of compiling and executing this C?
int x = 1, y = 10;
while (x < y) {
printf("%d\n", x*y);
x = x + 1;
y = y - 1;
}
1 + 1/2 + 1/3 + .... + 1/nFor example:
% a.out Enter n: 2 1.5 % a.out Enter n: 10 2.9289682539682538
4 - 4/3 + 4/5 - 4/7 + 4/9 - 4/11 + .....You must invent a suitable stopping condition.
Recall from lectures that the function rand() yields a pseudom-random int.
First, write a C program which simulates rolling the pair of dice once. The output from your program should look like this:
% a.out You rolled 1 and 2 = 3 % a.out You rolled 5 and 5 = 10 % a.out You rolled 6 and 2 = 8Second, modify the program to ask the user how many times to roll the dice. The output from your program should look like this:
% a.out How many times should I roll the dice? 5 You rolled 5 and 1 = 6 You rolled 1 and 5 = 6 You rolled 6 and 1 = 7 You rolled 4 and 3 = 7 You rolled 4 and 2 = 6Third, modify the program to also output a tally of the number of sevens rolled. The output from your program should look like this:
% a.out How many times should I roll the dice? 5 You rolled 2 and 2 = 4 You rolled 3 and 1 = 4 You rolled 2 and 5 = 7 You rolled 6 and 4 = 10 You rolled 2 and 5 = 7 2 7s were rolled
Recall from lectures that the function rand() yields a pseudom-random int.
Write a C program which asks the user how many times to roll a pair of 6 sided dice and prints a tally of all the numbers rolled. Don't output zero tallies. The output from your program should look like this:
% a.out How many times should I roll the dice? 8 You rolled 4 and 6 = 10 You rolled 1 and 2 = 3 You rolled 4 and 6 = 10 You rolled 6 and 5 = 11 You rolled 3 and 6 = 9 You rolled 1 and 2 = 3 You rolled 5 and 4 = 9 You rolled 3 and 6 = 9 2 3s were rolled 3 9s were rolled 2 10s were rolled 1 11s were rolled
Use an array to store the tallies.