Question
Please help me!

For Problem 1, 2 and 3: You are required to submit three .c files that contain the instructions that you have written to solve the following problems. Place the C source code to solve the first problem in a file called lab5a.c. Place the C source code to solve the second problem in a file called lab5b.c. And place the C source code to solve the third problem in a file called lab5c.c. Remember to include your name, due date of the problem and question index in the beginning of every C program file that you submit following pattern below

Problems: 1. Write a program to define an array of size 10, ask the user to enter the array elements. Replace all EVEN elemen
The output will be: The sum of row 1 in A and B = 0+1+2+2+3+1=9 The sum of row 2 in A and B = 3+4+5+5+6+3= 26 The sum of row
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Thanks for the question


Below is the code you will be needing Let me know if you have any doubts or if you need anything to change.


Thank You !!

Note:
As HOMEWORKLIB strict policy & guidelines, I am only allowed to answer the first question with the first 4 subparts, please post the remaining questions as a separate post, and I will be happy to answer them. Sorry for the inconvenience caused.

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

// PROBLEM 1
#include<stdio.h>

int main(){
  
   int numbers[10];
   int i=0;
  
   printf("Enter 10 elements, please: \n");
   for(i=0;i<10;i++){
       scanf("%d",&numbers[i]);
   }
  
   for(i=0;i<10;i++){
       if(numbers[i]%2==0)numbers[i]=1;
       else numbers[i]=0;
   }
  
   for(i=0;i<10;i++){
       printf("%d ",numbers[i]);
   }
}

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

// PROBLEM 2
#include<stdio.h>

int main(){
  
   int A[3][3]={{0,1,2},{3,4,5},{6,7,8}};
   int B[3][3]={{0,0,0},{0,0,0},{0,0,0}};
  
   int i=0;int j=0;
   printf("Enter the values of array B: \n");
   for(i=0;i<3;i++){
       for(j=0;j<3;j++){
           scanf("%d",&B[i][j]);
       }
   }
   int sum=0;
   for(i=0;i<3;i++){
       sum=A[i][0]+A[i][1]+A[i][2]+B[i][0]+B[i][1]+B[i][2];
       printf("The sum of row %d in A and B = %d\n",i+1,sum);
   }
  
  

}

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

// PROBLEM 3
#include<stdio.h>
#include<stdlib.h>

int main(){


   int size;
   printf("Enter the size of array, please: ");
   scanf("%d",&size);
  
   int *p_array = (int*)malloc(size*sizeof(int));
   printf("Enter the elements of the array, please: \n");
  
   int i=0;
   for(i=0; i<size;i++){
       scanf("%d",p_array+i);
   }
  
   int search_value;
   printf("Enter the element to search: ");
   scanf("%d",&search_value);
  
   int matches=0;
   for(i=0;i<size;i++){
       if(*(p_array+i)==search_value){
           if(matches==0){
               printf("%d exists in index: %d ",search_value,i);
               matches+=1;
           }else{
               printf("%d ",i);
               matches+=1;
           }
       }
   }
   if(matches==0){
       printf("%d does not exist",search_value);
   }
   free (p_array);
}

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

Add a comment
Know the answer?
Add Answer to:
Please help me! For Problem 1, 2 and 3: You are required to submit three .c...
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
  • Please solve this question using c++ language Problem 2. More Probleml. The program builds the array...

    Please solve this question using c++ language Problem 2. More Probleml. The program builds the array of integers that contains duplicates as well. Your program should find the sum of all unique elements in the array using a function findUniqueSum Arrays Write a program that as before asks the user to enter input as in оn Sample Input/Output Enter a list of numbers ending with -999 3 1 4 55-999 The sum of unique numbers is: 13 Enter a list...

  • Subset Sum-2 Write an algorithm (in comments) and specify the big O, and a C program...

    Subset Sum-2 Write an algorithm (in comments) and specify the big O, and a C program to solve the problern below. Read the input for the set elements, the value of K from the user. Assume the size of the set is not bigger than 20. Subset Sum-3 Write an algorithm (in comments) and specify from the user. Assume the size of the set is not bigger than 20 1. Given a finite set of integers, is there a subset...

  • Please help C++ language Instructions Write a program that prompts the user to enter 50 integers...

    Please help C++ language Instructions Write a program that prompts the user to enter 50 integers and stores them in an array. The program then determines and outputs which numbers in the array are sum of two other array elements. If an array element is the sum of two other array elements, then for this array element, the program should output all such pairs.

  • Program in C++! Thank you in advance! Write a menu based program implementing the following functions: (1) Write a funct...

    Program in C++! Thank you in advance! Write a menu based program implementing the following functions: (1) Write a function that prompts the user for the name of a file to output as a text file that will hold a two dimensional array of the long double data type. Have the user specify the number of rows and the number of columns for the two dimensional array. Have the user enter the values for each row and column element in...

  • //please help I can’t figure out how to print and can’t get the random numbers to...

    //please help I can’t figure out how to print and can’t get the random numbers to print. Please help, I have the prompt attached. Thanks import java.util.*; public class Test { /** Main method */ public static void main(String[] args) { double[][] matrix = getMatrix(); // Display the sum of each column for (int col = 0; col < matrix[0].length; col++) { System.out.println( "Sum " + col + " is " + sumColumn(matrix, col)); } } /** getMatrix initializes an...

  • FINAL Project 1-) Please submit the solution of your final as Ms-word or PDF document 2-)...

    FINAL Project 1-) Please submit the solution of your final as Ms-word or PDF document 2-) Complete THREE QUESTIONS out of the four exam questions below. 3-) FOR EACH QUESTION, IT IS REQUIRED to include Ms-Word or Pdf file contains the following A. Source file and sample of your output screen shots. B. Up to one page of your program discussion. In the discussion, state the issues that you may have problem with if there is any. Why your program...

  • In C++ please! Please include .cpp and .hpp files! Thank you! Recursive Functions Goals Create and...

    In C++ please! Please include .cpp and .hpp files! Thank you! Recursive Functions Goals Create and use recursive functions In this lab, we will write a program that uses three recursive functions. Requirements: Important: You must use the array for this lab, no vectors allowed. First Recursive Function Write a function that recursively prints a string in reverse. The function has ONLY one parameter of type string. It prints the reversed character to the screen followed by a newline character....

  • Here is the Prompt for problem 1: Write a C++ program that reads in a test file. The first numbe...

    Here is the Prompt for problem 1: Write a C++ program that reads in a test file. The first number in the file will be an integer, and will indicate the amount of decimal numbers to follow. Once you have the read the numbers from the file into an array then compute the following properties on the set of numbers: the sum, the average (mean), the variance, the standard deviation, and the median. Don’t try to do the entire program...

  • This is a C program. please help me to write a pseudocode of the program ....

    This is a C program. please help me to write a pseudocode of the program . also, I want the program In a do...while loop and the screen output should look like in the picture. please help me. 3.1. Write a program that asks the user to continue to enter two numbers (at a time). For each pair of numbers entered, the program calculates the product of those two numbers, and then accumulate that product. For each pair of numbers...

  • in C++ please ELET 2300 Programming Assignment # 2 Write a program that generates an array...

    in C++ please ELET 2300 Programming Assignment # 2 Write a program that generates an array filled up with random positive integer number ranging from 15 to 20, and display it on the screen. After the creation and displaying of the array, the program displays the following: [P]osition [Reverse, [A]verage, (Search, [Q]uit Please select an option: Then, if the user selects: -P (lowercase or uppercase): the program displays the array elements position and value pairs for all member elements of...

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