You are on page 1of 2

EDP 101/L (02921): COMPUTER FUNDAMENTALS AND PROGRAMMING

(FINAL REQUIREMENTS)

Andrei Patrick D. Borja

1. Declare an array to hold the tax for up to 10 different sales.

Source code (answer): Ouput:

#include <iostream>
using namespace std;

int main (){


int taxsales[10] = {} ;
for (int i=0;i<10;i++){
cout<<”Tax sales: “;
cin>> taxsales [i];
}
}

2. Declare an array to hold the final letter grades for a class with up to 40 students.

Source code (answer): Output:


#include <iostream>
using namespace std;

int main(){
string lettergrades[40];

for (int i=0;i<40;i++){


cout<<”Enter final letter grades: “;
cin>> lettergrades [i];
}
}
3. Declare an array of integers which holds the final average for those 40 students and initialize its
value to 0.

Source code (answer): Output:


#include <iostream>
using namespace std;
int main(){
int finalaveragegrade[40];
float a,sum,ave;
for(int i=1;i<40;i++){
cout<<”Student no: “ << i << “\tFinal grade: “;
cin>>finalaveragegrade[i];
}
}

4. Declare an array of characters called letter_ary with initial values ‘a’,’d’,’y’, and ‘w’. What is
the value of letter_ary[1]?

Source code (Answer):

#include<iostream>
using namespace std;

int main (){


char letter_ary[4] = {‘a’,’d’,’y’,’w’} ;
cout<<letter_ary[1];
}
Output:

You might also like