Sir Syed University of Engineering & Technology
Sir Syed University of Engineering & Technology
Sir Syed University of Engineering & Technology
int main()
{
int m, n;
for (m = 0; m < 10; m++) // for loop to repeat a specific number of times
{
cout << arr[m] << endl; // to print an array
}
return 0;
}
TASK : 2 Write a C++ program to find the sum and average of one dimensional
integer array.
#include<iostream>
using namespace std;
int main()
{
int a[10];
int s = 0;
float avg;
cout << "Enter values:" << endl;
for (int i = 0; i < 10; i++) //for loop to take numbers 10 times
{
cin >> a[i]; //input integer from user
s = s + a[i]; //formula of sum
}
cout << "Sum: " << s << endl;
avg = s / 10; //formula of average
cout << "Average: " << avg;
}
TASK : 3 Write a C++ program to swap first and last element of an integer 1-d
array.
#include <iostream>
using namespace std;
int main()
{
int m, a; // define variable
int num[10] = { 10,12,14,16,18,20,22,24,26,28 }; // Inilizing an Array
cout << "Swap first element with last element: " << endl;
#include <iostream>
using namespace std;
int main()
{
int a[5];
int m;
int main()
{
int array[5]; //initilizing an array
int m;
int large, small;
return 0;
}
TASK : 6