Write C++ programs to produce the output described in each ofthe following:
1- The largest factor of a number (the user supplies thenumber):
number = 24 , largest factor =12
2- An empty diamonds of stars ( the user supplies theheight)
*
* *
* *
* *
* *
* *
*
3- A pattern of 0’s surrounded by *’s ( the user supplies heightand width)
*************
*0*0*0*0*0*
*************
*0*0*0*0*0*
*************
Solution
#include <iostream>using namespace std;int main(){ int n; cout<<“Enter number: “; cin>>n; for(int i = n-1;i>=1;i–){ if(n%i == 0){
OR
OR