//lab 11a1.cpp
#include <iostream>
#include<cstring>
using namespace std;
void inputscores(int array[], int size);
int total(int array[], int size);
int main()
{
char name[20];
int scores[5];
int max;
cout << "Enter your name : ";
cin >> name;
cout << "Enter the numbers of scores : ";
cin >> max;
inputscores(scores,max);
cout << name << "'s Total runs is " << total(scores,max) << endl;
return 0;
}
void inputscores(int array[], int size)
{
int r;
for (r=0; r<size; r++)
{
cout << "Enter score " << r+1 << " : ";
cin >> array [r];
}
}
int total(int array[], int size)
{
int total=0;
for (int i=0; i<size; i++)
{
total = total + array[i];
}
return total;
}
#include<cstring>
using namespace std;
void inputscores(int array[], int size);
int total(int array[], int size);
int main()
{
char name[20];
int scores[5];
int max;
cout << "Enter your name : ";
cin >> name;
cout << "Enter the numbers of scores : ";
cin >> max;
inputscores(scores,max);
cout << name << "'s Total runs is " << total(scores,max) << endl;
return 0;
}
void inputscores(int array[], int size)
{
int r;
for (r=0; r<size; r++)
{
cout << "Enter score " << r+1 << " : ";
cin >> array [r];
}
}
int total(int array[], int size)
{
int total=0;
for (int i=0; i<size; i++)
{
total = total + array[i];
}
return total;
}
#include <iostream>
#include<cstring>
using namespace std;
void inputscores(int array[], int size);
int total(int array[], int size);
int main()
{
char name[20];
int scores[5];
int max;
cout << "Enter your name : ";
cin >> name;
cout << "Enter the numbers of scores : ";
cin >> max;
if (max>5)
{
int *data = new int[10];
inputscores(data,max);
cout << name << "'s Total runs is " << total(data,max) << endl;
delete []data;
}
else
{
inputscores(scores,max);
cout << name << "'s Total runs is " << total(scores,max) << endl;
}
return 0;
}
void inputscores(int array[], int size)
{
int r;
for (r=0; r<size; r++)
{
cout << "Enter score " << r+1 << " : ";
cin >> array [r];
}
}
int total(int array[], int size)
{
int total=0;
for (int i=0; i<size; i++)
{
total = total + array[i];
}
return total;
}
#include<cstring>
using namespace std;
void inputscores(int array[], int size);
int total(int array[], int size);
int main()
{
char name[20];
int scores[5];
int max;
cout << "Enter your name : ";
cin >> name;
cout << "Enter the numbers of scores : ";
cin >> max;
if (max>5)
{
int *data = new int[10];
inputscores(data,max);
cout << name << "'s Total runs is " << total(data,max) << endl;
delete []data;
}
else
{
inputscores(scores,max);
cout << name << "'s Total runs is " << total(scores,max) << endl;
}
return 0;
}
void inputscores(int array[], int size)
{
int r;
for (r=0; r<size; r++)
{
cout << "Enter score " << r+1 << " : ";
cin >> array [r];
}
}
int total(int array[], int size)
{
int total=0;
for (int i=0; i<size; i++)
{
total = total + array[i];
}
return total;
}
#include <iostream>
#include<cstring>
using namespace std;
void inputscores(int *array, int size);
int total(int array[], int size);
int main()
{
char name[20];
int scores[5];
int max;
cout << "Enter your name : ";
cin >> name;
cout << "Enter the numbers of scores : ";
cin >> max;
if (max>5)
{
int *data = new int[10];
inputscores(data,max);
cout << name << "'s Total runs is " << total(data,max) << endl;
delete []data;
}
else
{
inputscores(scores,max);
cout << name << "'s Total runs is " << total(scores,max) << endl;
}
return 0;
}
void inputscores(int *array, int size)
{
int r;
for (r=0; r<size; r++)
{
cout << "Enter score " << r+1 << " : ";
cin >> array [r];
}
}
int total(int array[], int size)
{
int total=0;
for (int i=0; i<size; i++)
{
total = total + array[i];
}
return total;
}
#include<cstring>
using namespace std;
void inputscores(int *array, int size);
int total(int array[], int size);
int main()
{
char name[20];
int scores[5];
int max;
cout << "Enter your name : ";
cin >> name;
cout << "Enter the numbers of scores : ";
cin >> max;
if (max>5)
{
int *data = new int[10];
inputscores(data,max);
cout << name << "'s Total runs is " << total(data,max) << endl;
delete []data;
}
else
{
inputscores(scores,max);
cout << name << "'s Total runs is " << total(scores,max) << endl;
}
return 0;
}
void inputscores(int *array, int size)
{
int r;
for (r=0; r<size; r++)
{
cout << "Enter score " << r+1 << " : ";
cin >> array [r];
}
}
int total(int array[], int size)
{
int total=0;
for (int i=0; i<size; i++)
{
total = total + array[i];
}
return total;
}
0 comments:
Post a Comment