What's wrong with the following programs?
/*********************************************************************************
This progam is design to let the user know a lottery number and that person name.
**********************************************************************************/
#include<iostream>
#include<string>
using namespace std;
void main()
{
string Username;
int num;
cout<<"What are your lottery number?"<<endl;
cin>>num;
cin>>Username;
cout<<"They are "<<num<<"."<<endl;
}
/***Try to compile, link and run it. If you are a user, can you know what to do without looking the codes?
Missing the USER & PROGRAMMER INTERFACE. ****/
#include<iostream>
#include<string>
#include<iomanip>
using namespace std;
void main()
{
int A,B,C,D,E,F,sum,product;
cout<<"enter two numbers"<<endl;
cin>>A>>B;
cout<<"enter two numbers"<<endl;
cin>>C>>D;
cout<<"enter two numbers"<<endl;
cin>>E>>F;
sum=A+B;
product=A*B;
cout<<setw(10)<<"number1"<<setw(10)<<"number2"<<setw(15)<<"sum"<<setw(15)<<"product"<<endl;
cout<<setw(10)<<A<<setw(10)<<B<<setw(15)<<sum<<setw(15)<<product<<endl;
cout<<setw(10)<<C<<setw(10)<<D<<setw(15)<<sum<<setw(15)<<product<<endl;
cout<<setw(10)<<E<<setw(10)<<F<<setw(15)<<sum<<setw(15)<<product<<endl;
}
Are all of them correct?
#include <iostream>
#include <iomanip>
using namespace std;
void main()
{
int n1, n2, n3, n4, n5, n6;
cout<<" Please enter two numbers. "<<endl;
cin>>n1>>n2;
cout<<" Please enter two numbers. "<<endl;
cin>>n3>>n4;
cout<<" Please enter two numbers. "<<endl;
cin>>n5>>n6;
cout<<"Num1"<<setw(10)<<"Num2" <<setw(10)<<"Sum"<<setw(10)<<"Product"<<endl;
cout<< n1 <<setw(10)<< n2 <<setw(11)<< n1+n2 <<setw(10)<< n1*n2 <<endl;
cout<< n3 <<setw(10)<< n4 <<setw(11)<< n3+n4 <<setw(10)<< n3*n4 <<endl;
cout<< n5 <<setw(10)<< n6 <<setw(11)<< n5+n6 <<setw(10)<< n5*n6 <<endl;
}
Are they lined up well? Why not?