Programming Fundamentals
Programming Fundamentals
Assignment# 02 CLO# 02
Due Date: November 30, 2022 NAME:Haroon Afzal
Program:
#include<iostream>
using namespace std;
#include<iomanip>
int main ()
{ int n, Sqr_of_W;
if(n==0)
goto exit;
cout<<"\nEnter "<<n<<" 'w' and 'z' coordinates for each point (seperate with space):
"<<endl;
for(int i=1;i<=n;i++)//loop for given equations upto the number of points that user give
{
cout<<setw(10)<<i<<": ";
cin>>W>>Z;
Slope=((n*Mul_of_Sn_WZ)-(Sn_W*Sn_Z))/((n*Sqr_of_W)-(Sn_W*Sn_Z));//finding slope
using formula
b=Avg_of_Sn_Z-(Slope*Avg_of_Sn_W);
True_case://
char ch;
cout<<endl;
cin>>ch;
if(ch=='Z'|| ch=='z')
cout<<"Enter 'w' values,one per line.Terminate the program any time with(ctrl+d):
"<<endl;
while(cin>>W)
Y=(Slope*W)+b;
if(Z>0)
cout<<setw(10)<<"z= +"<<setprecision(2)<<Z<<endl<<endl;
else
cout<<setw(10)<<"Z= "<<setprecision(2)<<Z<<endl<<endl;
}
}
cout<<"\tGood Bye";
cout<<"\n\tInvalid....Try again?\n";
exit:
return 0;
OUTPUT: