1. Create an array of size 100 and assign some random number from 0 to 50 in it using rand() and Srand() function(your lab instructor will tell you about these functions).
Note: (Assume index number +5) is roll number of student. For example
45
50
34
1
23
45 are marks of Roll # L1F20BSCS5
34 are marks of Roll# L1F20BSCS7
2. Find the index of maximum point and print the roll# along with message “Winner” Note: (don’t use sorting code here)
3. Find the index of 2nd maximum points (using 1st maximum points) and print the roll# along with message “Runner up”
Note: (don’t use sorting code here)
4. Calculate average of array i.e., Sum of all points in array and divide them by size of array
5. Check if its lower than 25 or not? and print appropriate message on screen.
6. Create a new array of similar size and copy all numbers in new array. Now sort the new array in descending order and print all values
Challenge: Print the roll# of students having similar points
Sample Output:
Student_Points : 5 21 0 23 10 5
Student L1F20BSCS8 is Winner
Student L1F20BSCS6 is Runner up
Average of Students points are: 12.8
Average of points is below 25; hence participants are not good programmers
Students points in order are: 23 21 5 5 0
#include <stdio.h>
#include <stdlib.h>
#include <ctime>
int main() {
srand((unsigned) time(0));
printf("Your dice has been rolled! You got: \n ");
int result = 1 + (rand() % 6);
printf("%d \n", result);
switch (result) {
case 1:
printf("Your prize is our original T-shirt!");
break;
case 2:
printf("Your prize is our original cap!");
break;
case 3:
printf("Your prize is our original necklace!");
break;
case 4:
printf("Your prize is our original keychain!");
break;
case 5:
printf("Your prize is our original cup set!");
break;
case 6:
printf("Your prize is a set of original keychains!");
break;
default:
printf("Error");
break;
}
}
Comments
Leave a comment