Question

Using Dev C++, write a program to solve the problem as stated below. Write a program...

  1. Using Dev C++, write a program to solve the problem as stated below.
  2. Write a program will input a single integer value (all input will be exactly 8 digits long) and will store pairs of digits as individual integer values. The program will display the five 2-digit numbers as well as the average of these, each on their own line. Use a switch statement to print out Grade: and then either A (>=90), B ([80..89]), C ([70..79]), D ([60..69]) or F (<60) based on the calculated average.
    1. Sample
      1. Input: 54861398
      2. Output:       

54

86

13

98

Avg: 62.75

Grade: D

  1. Sample
    1. Input: 64536785
    2. Output:        

64

92

67

85

Avg: 77.00

Grade: D

  1. make use of a repetition structure (counter-controlled while loop) to shorten part of your code.
  2. Compile the program and correct errors.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Program:

#include<stdio.h>
#include<string.h>
#include<stdlib.h>

int main()
{
long number,num1,num2;
int sum=0,i,arr[4];
double avg;
printf("Enter 8 digit number: ");
scanf("%ld",&number);

//code to get 4 pairs
num1=number/10000;
num2=number%10000;

i=0;
while(i<=3)
{
if(i==0)
{
arr[i]=num1/100;
}
else if(i==1)
{
arr[i]=num1%100;
}
else if(i==2)
{
arr[i]=num2/100;
}
else if(i==3)
{
arr[i]=num2%100;
}
i++;
}
printf("\n4 pairs of %ld number: \n\n",number);
for(i=0;i<=3;i++)
{
printf("%d\n",arr[i]);
sum=sum+arr[i]; //sum of all pairs
}

avg=(double) sum/4; //average

printf("\nAvg: %.2f",avg);

switch((int)avg/10) //getting grade
{
case 10:
case 9:
printf("\nGrade: A\n");
break;
case 8:
printf("\nGrade: B\n");
break;
case 7:
printf("\nGrade: C\n");
break;
case 6:
printf("\nGrade: D\n");
break;
default:
printf("\nGrade: F\n");
  
}

return 0;
}

Output:

Add a comment
Know the answer?
Add Answer to:
Using Dev C++, write a program to solve the problem as stated below. Write a program...
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
  • Using Dev C++, write a program to solve the problem as stated below. Make use of...

    Using Dev C++, write a program to solve the problem as stated below. Make use of a repetition structure (counter-controlled while loop) to shorten part of your code Dont use array. Write a program will input a single integer value (all input will be exactly 8 digits long) and will store pairs of digits as individual integer values. The program will display the five 2-digit numbers as well as the average of these, each on their own line. Use a...

  • Write a program called printGPA. The program should contain at least 3 methods: main, gradeAverage, and...

    Write a program called printGPA. The program should contain at least 3 methods: main, gradeAverage, and letterGrade. The user will type a line of input containing the student's name, then a number that represents the number of scores, followed by that many integer scores (user input is in bold below). The data type used for the input should be one of the primitive integer data types. Here are two example dialogues: Enter a student record: Maria 5 72 91 84...

  • C++ 1. Write a program to check if two values are equal. The output should give...

    C++ 1. Write a program to check if two values are equal. The output should give the response "Both a and b are the same" or "a and b are not the same". 2. Write a program to take a test score and determine the grade A is 90-100, B is 80-89, C is 70-79, D is 60-69, F is 60 or below. BONUS - check for input validation (score over 100 or under 0)

  • how to solve this on c++? Write a program that reads a five digits integer, then...

    how to solve this on c++? Write a program that reads a five digits integer, then swaps the unit position digit with the ten thousandth position digit, also swap the tenth position digit with the thousandth position digit. Print the new number For example if the number is 37846 then the new number is 64873. Sample input / output: nter a five digits integer The new form of the number 37846 is 64873

  • [Using Python] Use the grade scale in the syllabus for this class, write a program that...

    [Using Python] Use the grade scale in the syllabus for this class, write a program that inputs a score, and prints the grade for that score. For example, if I input 90.0, your program should print A. Grading Scale is: 100% - 90% A 89% - 80% B 79% - 70% C 69% - 60% D 59% - 0% E

  • Write a C++ program that asks the user for an exam score. The program displays on...

    Write a C++ program that asks the user for an exam score. The program displays on the screen the appropriate later grade as per the schema below: a. A: [90-100] b. B: [80:89] c. C: [70:79] d. D: [60:69] e. F: otherwise

  • SOLVE IN PYTHON:Exercise #1: Design and implement a program (name it AssignGrades) that stores and processes...

    SOLVE IN PYTHON:Exercise #1: Design and implement a program (name it AssignGrades) that stores and processes numeric scores for a class. The program prompts the users to enter the class size (number of students) to create a single-dimensional array of that size to store the scores. The program prompts the user to enter a valid integer score (between 0 and 100) for each student. The program validates entered scores, rejects invalid scores, and stores only valid scores in the array....

  • i need this program in DEV C and starts with include stdio.h only Write a program...

    i need this program in DEV C and starts with include stdio.h only Write a program that receives two input values: a float number x=0, and an integer N>3. The program should output Y, which is the product of all the N numbers divided by x.

  • Program : Write a complete C++ program that Input: Read a positive integer from the keyboard...

    Program : Write a complete C++ program that Input: Read a positive integer from the keyboard (user) with proper prompt text and save it to a variable. The integer have up to five digits. Processing: From the right most digit, extract every digit from the input integer using modular operator %then save the digit to a separate variable. Remove the right most digit from the integer using integer division operator /. Repeat above two steps till all digits have been...

  • Solve This Problem using python and please comment on every line. also, use function to solve...

    Solve This Problem using python and please comment on every line. also, use function to solve this. thanks The result will be like as below: Write a program that asks the user to enter five test scores. The program should display a letter grade for each score and the average test score. Write the following functions in the program: This function should accept five test scores as arguments and return the average of the scores. This function should accept a...

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