Welcome

Hi! This blog is for beginners of c++ and java .You can check and pick codes for your programming assignments. This will also help you to understand the concepts of these programming languages. Its all about programming.

Guess your answer(Of adding 5 numbers)

Thursday, June 2, 2011

/*Three numbers will be entered by user and the rest of two will be added automatically by Computer.Your answer will be shown after the input of First Number*/
#include<iostream>
using namespace std;
#include<conio.h>
void main()
{
int a,b,c,d,e,sum;
cout<<"All integers should be from 100 to 999"<<endl<<"you will enter 3 integers and computer will 2 extra number automatically to it"<<endl;
cout<<"As you enter first integer the computer will tell you the sum of all 5 integers"<<endl<<"Enter first integer:"<<endl;
cin >> a;
a-=2;
if(a+2==100||a+2==101)
{
cout<<endl<<"20"<<a<<" will be your answer:"<<endl<<endl;
}
else
{
cout<<endl<<"2"<<a<<" will be your answer:"<<endl<<endl;
}
a+=2;
cout<<"Enter second integer:"<<endl;
cin>>b;
c=999-b;
sum=a+b+c;
cout<<"Enter third integer:"<<endl;
cin>>d;
e=999-d;
sum=sum+d+e;
cout<<a<<"+"<<b<<"+"<<c<<"+"<<d<<"+"<<e<<"="<<sum<<endl;
getch();
}