Professional Documents
Culture Documents
LAB # 11
REG # 200901099
SUBMITTED BY:IRTAZA ALI NASIR
ASSINGED PROGRAM
#include<iostream>
using namespace std;
int main() {
char irt[100], * pt;
int i = 0;
return 0;
}
RESULT ON SECREEN
3. Write a program to combine two string by using pointer without using any built-
in function of strings..
ASSINGED PROGRAM
#include <iostream>
while (*(++s1));
return 0;
RESULT ON SECREEN
Q.3 Write a program that takes an array large enough to hold a user-defined
number of test scores. Once all the scores are entered, the array should be
passed to a function that sorts them in ascending order. Another function
should be called that calculates the average score. The program should
display the sorted list of scores and averages with appropriate headings.
ASSINGED PROGRAM
#include <iostream>
using namespace std;
void sorting(int arr[20], int n) {
int temp = 0;
for (int i = 0;i < n;i++)
{
for (int j = i + 1;j < n;j++)
{
if (arr[i] > arr[j])
{
temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
}
}
cout << " Ascending Order " << endl;
for (int i = 0;i < n;i++)
cout << arr[i] << endl;
cout << endl;
}
void average(int arr[20], int n)
{
int sum = 0;
int avg = 0;
for (int i = 0; i < n; i++)
{
sum += arr[i];
}
avg = sum / n;
cout << " AVERAGE " << endl << avg;
}
int main()
{
int arr[20];
int n = 0, temp = 0, avg = 0;
cout << "ENTER TOTAL NUMBER OF SCORES: " << endl << endl << " NOTE : YOU CANNOT
PUT MORE THEN 20 SCORES" << endl << endl;
cin >> n;
if (n < 0 || n>20)
{
cout << "INVALID VALUE PLZ READ NOTE CAREFULLY AND TRY AGAIN" << endl;
}
else
{
for (int i = 0;i < n;i++)
{
cout << "ENTER SCORE " << i + 1 << " : ";
cin >> arr[i];
}
}
sorting(arr, n);
average(arr, n);
}
RESULT ON SECREEN