Q .1 )An election is contested by five candidates.
The Candidates are numbered 1 to 5 & the
voting is done by marking the candidates
number on the ballot paper.Write a prog
to read the ballots and count the votes cast
for each candidate using an array variable count.
In case a number read is outside the range 1 to 5,
the ballot should be considered as a 'spoilt ballots'
and the prog should also count the number of spoilt
ballots.

Q.2) Write a function that creates a vector of user-given
size M using new operator.

Q.3) sinx=x-(x^3/3!)+(x^5/5!)-(x^7/7!)+.....................

Q1 and Q1 are not that difficult -- try to write them yourself. Have no clue what Q3 is supposed to be. The trailing periods have no meaning.

Q1: create an array of 5 ints, initialize them to 0. Then use ifstream object to read the file one int at a time. After verifying that the number just read is in valid range 1-5 use it as an index into the array. Here is a hint:

int array[5] = {0};
int index;
cin >> index;
if( index > 0 && index < 6)
   array[index-1]++;

People here are really very strict about this. Post your code please.:)

Q3 is a kind of fun one. Are you being asked to identify/describe what it is, what it's doing? Or are you to write the code that implements it?

Hint - lots of loops. How would you make it alternately add then subtract?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.