1) a) What would be the output of the program? Run the program with 10 20 30 40.
b) What does the program do?
#include <iostream.h>
main()
{ int table[10] , n = 0, i, nko, upubm;
cout<<" ENTER THE
DATA: " << endl;
while (cin>>
table[n]) {n++;}//while
for(i=0;i<n;i++){ cout << " i is "<<i<<"table[i]="<<table[i]<<endl;}//for
nko = table[0];
for (i
= 1; i<n; i++)
{ if (table[i] < nko)
nko = table [i];
}//for
for (i
= 0; i < n; i++){
upubm = upubm + table[i];
}//for
cout << " THE NKO IS
" << nko << endl;
cout << " THE UPUBM
IS " << upubm << endl;
}//main
2) a) What
is the output of the below program? Run the
program with 10.0, 20.0 5.0 20.0
//function
prototypes
int inputin (double
itemp[]);
double comptot
(double itemp[], int cnt);
double findmax
(double itemp [], int cnt);
double compavg
(double tot, int ent);
void printdata(double itemp[], int cnt,
double tot, double
mx, double av);
#include <iostream.h>
void main(){
int cnt;
double itemp[100],
av, tot, mx;
cout<<" CALLING INPUT
"<<endl;
cnt = inputin(itemp);
cout<<"CALLING TOTAL:
" <<endl;
tot = comptot(itemp, cnt);
cout<<"CALLING
MAXIMUM "<<endl;
mx = findmax
(itemp, cnt);
cout<<"CALLING AVERAGE"
<<endl;
av = compavg(tot,
cnt);
cout<<"CALLING PRINT
OUT "<<endl;
printdata(itemp, cnt,
tot, mx, av);
}//end
main
int inputin (double
itemp[]){int
cnt = 0;
cout<<"ENTER THE
ITEM: ";
while
(cin>>itemp[cnt]) {cnt = cnt
= 1;
cout<<"ENTER
THE ITEM: ";} //end while
return cnt;
}//end
inputin
double comptot(double itemp[], int cnt){
double tot = 0;
for (int i= 0; i<cnt; i++){
tot = tot + itemp[i];} //end for
cout <<"TOTAL:
"<<tot<<endl;
return tot;
}
//end comptot
double
findmax (double itemp[], int
cnt) {double mx;
mx = itemp[0];
for (int i
= 0; i<cnt; i++){
if
(itemp[i]>mx){mx = itemp[i];}// end if
}//end for
return
mx;}
double
compavg(double tot, int cnt){
double
av;
av = tot/cnt; return av;}
void printdata (double itemp[], int
cnt, double tot, double mx, double av){
for (int i
= 0; i<cnt; i++){cout << itemp[i]<<endl;}//end for
cout<<
"CNT IS: "<<cnt << " TOT
IS: " << tot << endl;
cout
<<" AV IS: "<<av<<"
MX IS : "<<mx<<endl;
} //end print
3)a) Comple the following Search Program
main ()
{
............int MAXSIZE = 6;
long int accountnumber
[]=
{123490, 569876, 543689,
107412, 11111, ........};
double accountbalance......=
{230.90, 789.00, 99.00, 986.54, 1.00, 340.44};
long int.....................;
cout<<"PLEASE ENTER
THE.............: ";
cin>>searchaccountnumber;
for (int i = 0; i <MAXSIZE;.......){
..................(.............[.]== searchaccountnumber){
cout<<"BALANCE
IS :"<<.................<<endl;
...............1;
}//end if
}//end
for
cout<<.......
..............;}//end
main
3b)
Complete the following selection sort program.
Program each time finds the minimum
value and place it at the beginning
location.
const ............n = 100;
int tbl[........], minloc,
pass, I;
for (pass = 0; pass < n-1,
pass.......){
minloc =
pass;
for (i=pass + 1; i,n; i++){
if
tbl[i]<tbl[.........]) {minloc = i} //end for...........
int temp = tbl
[minloc];
tbl[....]=tbl[I];
tbl[i]=temp;
}//end for ..................
4)Design a simple database “Grading
System” for Professor Ebrahimi with the following
functions:
append(), display(), search (),
modify(), and delete()
a)
Show
the main menu
b) Show the function insert
c) Show the
function modify.
5) How can the grading system be improved using
different data structures such as arrays and random access files?
What is the problem with modification and
deletion?
a)
Show
the insertion function
b) Show the deletion function
c) Indicate one advantage and
one disadvantage for each method versus the other
6) Declare the user data type called Student using a structure or class.
b) show the
insertion functions fro the above.
c) show the
structure using a linked list
d) Show display fuction
using linked list.