Question

Use the array definition given. Write a program to achieve the pseudocode provided below. What is the final value of CREDIT?

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

question1:

#include <stdio.h>

int main()
{
int marks[]={15,20,10,4,12};
int credit=0; //initial value of credit
for(int i=0;i<5;i++)
{
if(marks[i]>10)
credit=credit+2;
else if(marks[i]>0&&marks[i]<=10)
credit=credit+1;
else
credit=credit;
}
printf("Final credit : %d ",credit);
return 0;
}
{ main.c 1 #include <stdio.h> 2 3 int main() 4. { 5 int marks []={15,20,10,4,12}; 6 int credit=0; //initial value of credit 7

#include <stdio.h>
int main()
{
int array[10],sum=0,i,smallest,largest;
printf("Enter 10 values into array");
for( i=0;i<10;i++)
scanf("%d",&array[i]);
smallest=array[0];
largest=array[0];
for(i=0;i<10;i++)
{
sum=sum+array[i];
if(array[i]<smallest)
smallest=array[i];
if(array[i]>largest)
largest=array[i];
}
printf("Total sum : %c %d",(sum>0)?'+':'-' , sum);
printf("\nThe smallest : %d",smallest);
printf("\nThe largest : %c %d",(largest>0)?'+':'-' ,largest);
return 0;
}

{ main.c 1 #include <stdio.h> 2 int main() 3-{ 4 int array[10], sum=0,i, smallest, largest; 5 printf(Enter 10 values into ar

Add a comment
Know the answer?
Add Answer to:
Use the array definition given. Write a program to achieve the pseudocode provided below. What is...
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 a C++ program that will create an array with a given number of elements. Use...

    Write a C++ program that will create an array with a given number of elements. Use size = 10 for demonstration purposes, but write the program where the size of the array can be changed by changing the value of one constant. Fill the array with random numbers between 0 and 100. Write the program to perform the following operations: 1. Find and display the largest value in the array. 2. Find and display the smallest value in the array....

  • Write a JAVA program to sort a given array of integers (1 Dimensional) in ascending order...

    Write a JAVA program to sort a given array of integers (1 Dimensional) in ascending order (from smallest to largest). You can either get the array as input or hardcode it inside your program.

  • using matlab In Class Exercises 8-Arrays For the following exercises, assume an array is already populated, your job is to write a program that traverses the array. DO NOT HARD CODE the last in...

    using matlab In Class Exercises 8-Arrays For the following exercises, assume an array is already populated, your job is to write a program that traverses the array. DO NOT HARD CODE the last index. In other words, you code for 1-4&6 should be able to handle the following 2 arrays: amp2 10 array1 [52, 63, 99, 71, 3.1] array2 - [99:-3: 45); For 5: wordArray1 wordArray2 ('number, 'arrays', 'indices', 'hello', finish' [number, 'different, 'finish? 1. Determine the sum of all...

  • Write a C PROGRAM that will read in 10 floating-point numbers from the keyboard and load...

    Write a C PROGRAM that will read in 10 floating-point numbers from the keyboard and load them into an array. Add up all the values and store the answer in a variable. Find the largest and smallest number in the array. Put each into its own variable. Print to the screen the sum, largest value, and smallest value. Copy the array to a second array in reverse order. Print out the second array. Read in 20 integer numbers, all in...

  • Use C++ (2D Array) Write a program which: 1. Assigns data given below into the 2D...

    Use C++ (2D Array) Write a program which: 1. Assigns data given below into the 2D array of integers which is 10x10. 2. Prints out the contents of the 2D array after assigning the data to make sure correct data was assigned. 3. Figures out and prints out the square root of the sum of ALL the elements in the 2D array. 4. Figures out and prints out the average of ALL THE ELEMENTS in the 2D array. 5. Figures...

  • Write a program that scores the total rainfall for each of 12 months into an array...

    Write a program that scores the total rainfall for each of 12 months into an array double. A sample array definition is shown below double thisYear[] = {1.6, 2.1, 1.7, 3.5, 2.6, 3.7, 3.9, 2.6, 2.9, 4.3, 2.4, 3.7}; The program should have the four functions to calculate the following 1. The total rainfall for the year 2. The average monthly rainfall 3. The month with most rain 4. The month with least rain Output: What to deliver? Your .cpp...

  • Given below is a partially completed C program, which you will use as a start to...

    Given below is a partially completed C program, which you will use as a start to complete the given tasks. #define SIZE 9 #include <stdio.h> int compareAndCount (int[], int[]); double averageDifference (int[], int[]); void main() { } int compareAndCount(int arr1[SIZE], int arr2[SIZE]) { int count - @; for (int i = 0; i < SIZE; i++) { if (arri[i] > arr2[i]) count++; return count; Task 1: (10 pts) Show the design of the function compareAndCount() by writing a pseudocode. To...

  • Write a C++ program to fill a vector with 5000 random numbers. Then display: The smallest...

    Write a C++ program to fill a vector with 5000 random numbers. Then display: The smallest number The largest number The number of odd values The number of even values The total of the values The average of the values Ask the user for an integer and display the subscript of the cell where it was found or NOT FOUND! if it isn’t found. There is a file called "Activity 25 Sort functions.zip" under Materials in this week’s module. Download...

  • Write a single program in java using only do/while loops for counters(do not use array pls)...

    Write a single program in java using only do/while loops for counters(do not use array pls) for the majority of the program and that asks a user to enter a integer and also asks if you have any more input (yes or no) after each input if yes cycle again, if not the program must do all the following 4 things at the end of the program once the user is finished inputting all inputs... a.The smallest and largest of...

  • Write a program that instantiates an array of integers named scores. Let the size of the...

    Write a program that instantiates an array of integers named scores. Let the size of the array be 10. The program then first invokes randomFill to fill the scores array with random numbers in the range of 0 -100. Once the array is filled with data, methods below are called such that the output resembles the expected output given. The program keeps prompting the user to see if they want to evaluate a new set of random data. Find below...

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