code:
#include<stdio.h>
void main()
{
int sum=0,i;
int a[20];
printf("Enter array elements");
for(int i=0;i<8;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<8;i++)
{
if(a[i]%2==0)
{
sum=sum+a[i];
}
}
printf("%d",sum);
}
Q1. Write an algorithm (pseudocode or flowchart) for the following problem. Input: Eight integers Output: the...
Q1. [10 pts] Write an algorithm for Bubble sort that sorts array of n integers. Indicate the expected time complexity of the algorithm using the big-O notation. Use the following format for an algorithm pseudocode Function header (.....) Input: Output: Algorithm steps: 1. 2.
Consider the following problem: Input: a list of n-1 integers and these integers are in the range of 1 to n. There are no duplicates in list. One of the integers from 1 to n is missing in the list. Output: find the missing integer Let the input array be [2, 4, 1, 6, 3, 7, 8]. Elements in this list are in the range of 1 to 8. There are no duplicates, and 5 is missing. Your algorithm needs...
for matlab programming beginner level Q1) Write an algorithm for finding the prime numbers between 1 and 100 and displaying them. As you know; prime numbers are the ones that can only be divided by 1 and themselves, Example: 5 is a prime number. Write your algorithm in pseudocode and as flowchart. I
Q1: Write an algorithm and sketch the flowchart to read 20 numbers for x and finding the number of times that the number 100 is repeated between these numbers. (12 marks) Q2: What is the difference between prefix decrementer (- - i) and postfix decrementer (i - -) explain using examples. Q3: C++ includes a very special operator called the ternary operator. Explain with example how this operator used? Q4: Write C++ Program which output this result ******50 *****500 ****5000...
C programming! Write a program that reads integers until 0 and prints the sum of values on odd positions minus the sum of values on even positions. Let ?1, ?2, … , ??, 0 be the input sequence. Then the program prints the value of ?1 − ?2 + ?3 − ?4 + ⋯ ??. The input is a sequence of integers that always contains at least 0 and the output will be a single number. For example, for input...
(Do algorithm and flowchart) Q1 Write 2 functions: int reverse (int) which returns reverse of a number and int diff(int, int) which returns difference of two numbers. Using this Write a program to find whether a number given as input is palindrome or not
2. Given an array of integers, find two numbers such that they add up to a specific target number. Input: numbers (2, 7,1 15, target-9 (10 points) Output: index-, ndex2-2 3. Write an algorithm such that if an element in an MxN matrix is 0, its entire row and column is set to 0. (10 points) 2. Given an array of integers, find two numbers such that they add up to a specific target number. Input: numbers (2, 7,1 15,...
1. Create the algorithm for the following problem. Considering the first 20 natural numbers, calculate the sum of these numbers, the sum of their squares, and the sum of their cubes. Display all the sums at the end of the solution. Post your response as flowchart or pseudocode.
Q4. Write an algorithm, draw the flowchart and write a C++ program to • Read the Number and Letter from the user • Check the number and letter then print the corresponding month name as given in Table Q4 using IF ELSE STATEMENT. Table: Q4 Number and Letter Month Name JANUARY 2 F FEBRAURY 3 M MARCH 4 A APRIL Other numbers Invalid Input 1J Sample Output: Enter the value of number:1 Enter the value of letter:) JANUARY Algorithm: Flowchart:...
Sum of A1l Integers in a List (SUM) Input A list of integers Ala.. b] Output : s-Σ-, A[i] Let S(Ala...b]) represent the output of the SUM problem on input Ala..b 4 points) 5. Statetwo different elf-reductions for the SUM problem. Usethe self-reduction examples from lecture as a guide. (4 points) 6. Give recursive algorithms based on your divide and conquer self-reductions to solve the SUM problem. (2 points) 7. What are the worst case runtimes of the solutions you...