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
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
10 Years
Discussion Span
Last Post by vmanes

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