C Exercises: Total of two indices values equal a target
1. Two-Sum Indices Variants
Write a C program to get the indices of two numbers in a given array of integers. This will enable you to get the sum of two numbers equal to a specific target.
C Code:
Sample Output:
Original Array: 4 2 1 5 Target Value: 7 Indices of the two numbers whose sum equal to target value: 7 1 3
Pictorial Presentation:
Flowchart:

For more Practice: Solve these Related Problems:
- Write a C program to find indices of two numbers in an unsorted array that sum to a given target using a hash table.
- Write a C program to locate indices of two numbers in a sorted array whose sum equals the target using binary search for complements.
- Write a C program to identify indices of two numbers in a circular array that sum to a specified target.
- Write a C program to find indices of two numbers that sum to a target, ensuring the solution returns the smallest possible index pair.
C Programming Code Editor:
Contribute your code and comments through Disqus.
Previous C Programming Exercise: C programming Exercises Home
Next C Programming Exercise: No repeating characters in a substring.
What is the difficulty level of this exercise?
Based on 1292 votes, average difficulty level of this exercise is Medium
.
Test your Programming skills with w3resource's quiz.