Question

C programming. Write the code described in the picture with given 2 example executions of the code, and they must match. AND YOU CANT USE if statements!

Problem: Allow the user to enter a positive integer value to represent the seed value for the random number generator. Next,

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <stdio.h>

#include <stdlib.h>

int main() {

int n;

printf("Enter the seed value -> ");

scanf("%d", &n);

srand(n);

int val = rand()%1001;


printf("\nTotal Points Earned: %d\n",val);

printf("Course Grade Earned: ");

val >= 800 ?printf("A\n") :

(val >= 675 ? printf("B\n") :(val >= 550 ? printf("C\n") : (val >= 425 ? printf("D\n") : printf("F\n"))) );




return 0;

}

================================

SEE OUTPUT, No IF statement used

main.c 3 saved 1 #include <stdio.h> #include <stdlib.h> clang version 7.0.0-3-ubuntu0.1 > clang-7 -pthread -lm -o main } ./ma

Thanks, PLEASE COMMENT if there is any concern.

Add a comment
Know the answer?
Add Answer to:
C programming. Write the code described in the picture with given 2 example executions of the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write the code in C with all the right output please. Problem: In this assignment you...

    Write the code in C with all the right output please. Problem: In this assignment you will analyze a data set of 10,000 randomly generated integers. From this data set you will display a count of the prime numbers that are greater than the average (double) of the entire data set. The user will input only a single integer value to serve as the seed for the random number generator. The use of a common seed will result in output...

  • Write the Code in C program. Create a random password generator that contains a user-specified number...

    Write the Code in C program. Create a random password generator that contains a user-specified number of characters. Your program should prompt the user for the desired length of the password. Length of password: To create your password, use the random number generator in the stdlib.h C library. To generate random numbers, you will need the srand() and rand() functions. srand(seed) is used to "seed" the random number generator with the given integer, seed. Prompt the user for the seed...

  • In C++ Programming Write a program in a file named SeedFinder.cpp that finds and displays all...

    In C++ Programming Write a program in a file named SeedFinder.cpp that finds and displays all the seeds of a integer given by the user. Let’s define a seed of an integer, n, to be a positive value that equals n when multiplied by its individual digits. For example, 23 is a seed of 138 because 23 × 2 × 3 = 138. 111 is an example of a seed of itself because 111 × 1 × 1 × 1...

  • Please answer this questions in language C and make sure all executions work. Problem: Given an...

    Please answer this questions in language C and make sure all executions work. Problem: Given an integer as input determine if the digits in a second integer appear in the first integer in the same order (left to right, but not necessarily consecutive or at the same position). When the digits in the second integer (known as the target) do not appear in the first (known as the data) in the same order then identify the next integer value greater...

  • Intro to Programming in C – Large Program 1 – Character/ Number converter Assignment Purpose: To...

    Intro to Programming in C – Large Program 1 – Character/ Number converter Assignment Purpose: To compile, build, and execute an interactive program with a simple loop, conditions, user defined functions and library functions from stdio.h and ctype.h. You will write a program that will convert characters to integers and integers to characters General Requirements • In your program you will change each letter entered by the user to both uppercase AND lowercase– o Use the function toupper in #include...

  • please write c programming for this code below. Write a program to print a pattern of...

    please write c programming for this code below. Write a program to print a pattern of numbers separated by spaces for the given number of rows. At the time of execution, the program should print the message on the console as: Enter number of rows For example, if the user gives the input as: Enter number of rows : 4 then the program should print the result as: 232 34543 4567654

  • write programs with detailed instructions on how to execute. code is java What you need to...

    write programs with detailed instructions on how to execute. code is java What you need to turn in: You will need to include an electronic copy of your report (standalone) and source code (zipped) of your programs. All programming files (source code) must be put in a zipped folder named "labl-name," where "name" is your last name. Submit the zipped folder on the assignment page in Canvas; submit the report separately (not inside the zipped folder) as a Microsoft Word...

  • In C programming please (b) You will write a program that will do the following: prompt...

    In C programming please (b) You will write a program that will do the following: prompt the user enter characters from the keyboard, you will read the characters until reading the letter 'O' You will compule statistics concerning the type of characters entered. In this lab we will use a while loop. We will read characters from stdin until we read the character 'Q' Example input mJ0*5/1+x1@3qcxQ The 'Q' should be included when computing the statistics properties of the input....

  • write a code on .C file Problem Write a C program to implement a banking application...

    write a code on .C file Problem Write a C program to implement a banking application system. The program design must use a main and the below functions only. The program should use the below three text files that contain a set of lines. Sample data of these files are provided with the assessment. Note that you cannot use the library string.h to manipulate string variables. For the file operations and manipulations, you can use only the following functions: fopen(),...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT