Give two integer arrays A & B.A has n elements and B has ' n-1 ' elements . A has all the elements that are there in B. But B has one missing element. Write a function that takes arrays , A & B as imnput and finds the missing element in most optised manner .
Answer Posted / abhi
#include<iostream>
using namespace std;
#include<algorithm>
int main()
{
int n;
cin>>n;
int a[n],b[n-1];
int sum1=0,sum2=0;
for(int i=0;i<n;i++)
{
cin>>a[i];
sum1+=a[i];
}
for(int i=0;i<n-1;i++)
{
cin>>b[i];
sum2+=b[i];
}
cout<<sum1-sum2<<endl;
}
Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is stl language?
How do you convert stl to steps?
What is a list in c++ stl?
Write a C/C++ program to add a user to MySQL. The user should be permitted to only "INSERT" into the given database.
How stl is different from the c++ standard library?
What is meant by stl in c++?
What does stl mean in slang?
What do stl stand for?
What is a stl vector?
What are the various types of stl containers?
Explain stl.
When did c++ add stl?
how to making game in c++ ?
If P is the population on the first day of the year, B is the birth rate, and D is the death rate, the estimated population at the end of the year is given by the formula: The population growth rate is given by the formula: B – D Write a program that prompts the user to enter the starting population, birth and death rates, and n, the number of years. The program should then calculate and print the estimated population after n years. Your program must have at least the following functions: 1. growthRate: This function takes its parameters the birth and death rates, and it returns the population growth rate. 2. estimatedPopulation: This function takes its parameters the current population, population growth rate, and n, the number of years. It returns the estimated population after n years Your program should not accept a negative birth rate, negative death rate, or a population less than 2. please answer my question ....
help me i need a c++ program which takes sequesnce of characters and outputed sequence of their token taypes, work same compiler in lexical analysis phase