Professional Documents
Culture Documents
ASSIGNMENT NO. 3
PROGRAMING FUNDANETAL
#include <iostream>
int main()
smallest = num[0];
{ smallest = num[i]; }
cout << "The smallest number is: " << smallest << endl;
return 0;
}
Q2: Write a C++ program that input ten number from user using array and display the largest number?
#include <iostream>
int main()
largest = num[0];
{ largest = num[i]; } }
cout << "The largest number is: " << largest << endl;
return 0;
}
Q3: Take 10 integer inputs from user and store them in an array. Again, ask user to give a number. Now, tell user
whether that number is present in array or not.?
#include <iostream>
int main()
{ if(num[i] == search)
{ found = true;
break; } }
if(found)
{ cout << "The number " << search << " is present in the array." << endl; }
else
{ cout << "The number " << search << " is not present in the array." << endl; }
return 0;
}
Q4: Take 10 integer inputs from user and store them in an array. Now, copy all the elements in another array but in
reverse order?
#include <iostream>
int main()
return 0; }
Q5: Write a program that input ten number form user using array and find the sum and product of all elements of an
array?
#include <iostream>
int main()
{ int num[10];
int sum = 0;
int product = 1;
{ sum += num[i];
product *= num[i]; }
cout << "The sum of all elements is: " << sum << endl;
cout << "The product of all elements is: " << product << endl;
return 0; }
Q6: Write a C++ program to find the second lowest and highest numbers in a given array?
#include <iostream>
#include <algorithm>
int main() {
int num[10];
sort(num, num+10);
cout << "The second lowest number is: " << num[1] << endl;
cout << "The second highest number is: " << num[8] << endl;
return 0;