×
Samples Blogs Make Payment About Us Reviews 4.9/5 Order Now

Create a Program to Implement Arrays in C++ Assignment Solution

July 02, 2024
Dr. Benjamin Hughes
Dr. Benjamin
🇬🇧 United Kingdom
C++
Dr. Benjamin Hughes holds a Ph.D. in Computer Science from the University of Cambridge and has over 10 years of experience in software development and programming education. With expertise in Templated Linked Lists, he has completed over 800 assignments with precision and efficiency, helping students across the globe excel in their programming coursework.
Key Topics
  • Instructions
    • Objective
  • Requirements and Specifications
Tip of the day
Use Python libraries effectively by importing only what you need. For example, if you're working with data, using libraries like pandas and numpy can save time and simplify complex tasks like data manipulation and analysis.
News
In 2024, the Biden-Harris Administration has expanded high-dosage tutoring and extended learning programs to boost academic achievement, helping programming students and others recover from pandemic-related setbacks. These initiatives are funded by federal resources aimed at improving math and literacy skills​

Instructions

Objective

Write a C++ assignment program to implement arrays in .

Requirements and Specifications

program-to-implement-arrays-in-c++-assignment-solution
program-to-implement-arrays-in-c++-assignment-solution 1

Source Code

#include #include #include // A. bool checkDuplicates(int arr[], int n, int k) { for (int i = 0; i < n; i++) { int j = i + 1; int range = k; while (range > 0 && j < n) { if (arr[i] == arr[j]) return true; j++; range--; } } return false; } // B. void white_black(int pixels[][5], int rows){ int r, c; for(r=0; r<5; r++){ for(c=0; c<5; c++){ pixels[r][c] = 255 - pixels[r][c]; } } for(r=0; r<5; r++){ for(c=0; c<5; c++){ printf("%4d",pixels[r][c]); } printf("\n"); } } int main() { // A. int arr[10]; for(int i = 0; i< 10; ++i) { printf("Input number %d:",i+1); scanf("%d", &arr[i]); } int n = sizeof(arr) / sizeof(arr[0]); if (checkDuplicates(arr, n, 3)) printf("There are duplicate values \n"); else printf("There are not duplicate values \n"); printf("----------- \n"); // B. int pix[5][5] = { {183, 226, 180, 117, 222}, {193, 188, 0, 124, 52}, {46, 157, 214, 49, 246}, {1, 78, 167, 143, 204}, {98, 175, 159, 152, 248} }; white_black(pix,5); printf("----------- \n"); // C. int UPC[10]; float price[10]; float Total=0; for(int i = 0; i<10; ++i) { printf("Enter UPC #%d:",i+1); scanf("%d", &UPC[i]); printf("Enter price #%d:",i+1); scanf("%f", &price[i]); Total = Total + price[i]; } printf("Item "); printf("Code "); printf("Price \n"); for(int i=0; i<10; i++) { printf("%d ",UPC[i]); printf(" "); printf("%.2f ",price[i]); printf("\n"); } printf("Total "); printf(" "); printf("%.2f ",Total); }

Similar Samples

Discover our range of programming samples at ProgrammingHomeworkHelp.com, showcasing expertise in Java, Python, C++, and more. Each example illustrates our approach to solving complex programming challenges effectively. Explore these samples to gain insights into our high-quality solutions and how we can assist you in mastering programming concepts.