-1

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!)+.....................

4
Contributors
3
Replies
4
Views
9 Years
Discussion Span
Last Post by vmanes
0

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]++;
0

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?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.