Handwritten Text Recognition for manuscripts and early printed texts
Programming-I assignment for BSCS students , NCBA&e
1. NCBA&E
(National College of Business Administration & Economics)
Assignment On Prog. & Problem Solving-1
Submitted by
Hamna Ali
2. BSCS-2143246
Submitted to
Miss Atifa Athar
Oct. 9. 2014
Program 1: (Sum)
#include<iostream.h>
Int main()
{
int n1,n2 , sum;
cout<<"Enter first number=";
cin>>n1;
cout<<"Enter second number=";
cin>>n2;
sum=n1+n2;
cout<<"The sum is="<<sum;
5. Program 3: (find the Area of a Rectangle)
#include<iostream.h>
int main()
{
int ˥,w, area;
cout<<"Enter length=";
cin>>˥;
cout<<"Enter width=";
cin>>w;
area=˥*w;
cout<<"The Area="<<area;
return 0;
}
Output:
Enter length=8
6. Enter width=6
Area=l*w
so,
Area is =48
Program 4: (Find Smaller of Two numbers using If Else statement)
#include<iostream.h>
main()
{
int n1,n2, smaller;
cout<<"Enter First no=";
cin>>n1;
cout<<"Enter Second no=";
cin>>n2;
if (n1<n2)
{
smaller=n1;
}
else
8. {
int a,b,c;
cout<<"Enter the value of a=";
cin>>a;
cout<<"Enter the value of b=";
cin>>b;
c=a*b;
cout<<"The product of a & b is="<<c;
return 0;
}
Output:
Enter the value of a: 2 Enter the value of b:4 Product of a&b is=8
Program: 6 (Find Difference of two numbers using condition)
#include<iostream.h>
main ()
{
int n1,n2, difference;
9. cout<<"Enter First no=";
cin>>n1;
cout>>"Enter Second no=";
cin<<n2;
difference=n1-n2;
if (difference<0)
{
difference=difference*(-1);
}
cout <<difference;
return 0;
}
Output:
Enter first number:5
Enter second number:2
Difference of two numbers is 3
10. Program : 7 (Program that inputs a number and finds whether
it is even or odd using if-else statement).
#include<iostream.h>
main()
{
int n;
cout<<"Enter a number:";
cin>>n;
if (n%2==0)
cout<<n<<" is even.";
else
cout<<n<<" is odd.";
getch();
}
Output:
Enter a number:10
10 is even number.
11. Program :8 (Find division of two numbers)
#include<iostream.h>
int main()
{
cout<<"Enter first no=";
cin>>n1;
cout<<"Enter second no=";
cin>>n2;
divide=n1/n2;
cout<<"The division="<<divide;
return 0;