Dear all,
I am new to this and I need ur help.
I have the following problem description
Write a C++ program that defines 3 arrays of integers a, b, c and 3 integers counts cnt_a, cnt_b , cnt_c. The program must then ask the user for the number of elements cnt_a, to insert in array a and then read in the corresponding element values is such a way that no value inserted more than once. Explain what changes are required to perform the same for array b.
I have made the following code. It works fine but I am not checking if the value inserted is the same.Also I havent initialized the other variables. Any help is much apreciated.
// pointers.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
using namespace std;
int main()
{
int cnt_a=0; /* cnt_b, cnt_c;*/
int *a;/**b,*c;*/
bool valid=false;
int i=0;
cout <<"Please enter an integer number of elements for the array" << endl;
cin >> cnt_a;
a=new int[cnt_a];
if (cnt_a>1) {
valid=true; //set valid to false if value is less than 1
}//end if statement
while (valid){
for (i; i<cnt_a; i++){
cout <<"Now enter the " <<i+1<< " element of the array"<<endl;
cin >> a[i];
//Statements to check if the values of the elements are the same. If are the same prompt the user to enter again a number
}//end for loop
valid=false;
}//end while loop
return 0;
}
Thanks in advance!!!