Assignment#1: Name: Eysha Qureshi Reg. No: 130401032 EE-03-A Subject: Programming Language
Assignment#1: Name: Eysha Qureshi Reg. No: 130401032 EE-03-A Subject: Programming Language
Reg. No : 130401032
EE-03-A
Dated: 25/03/2014
Submitted to: Sir Ghulam Abbas
C++ PROGRAMS
Program #1:
Q.Write a program to add two numbers entered by user.
//Sum of two numbers entered by users
#include<iostream>
#include<conio.h>
using namespace std;
void main()
{
float num1,num2,sum;
cout<<" Enter the first number ";
cin>>num1;
cout<<" Enter the second number ";
cin>>num2;
sum=num1+num2;
cout<<" The sum of two numbers entered by the user is "<<sum<<endl;
cin.get();
getch();
}
Screen Shot
Program #2:
Q.Write a program to find the largest among three different numbers entered
by user.
//The largest number among three different numbers
#include<iostream>
#include<conio.h>
using namespace std;
void main()
{
float a,b,c;
cout<<"Enter the first number"<<endl;
cin>>a;
cout<<"Enter the second number"<<endl;
cin>>b;
cout<<"Enter the third number"<<endl;
cin>>c;
if (a>b)
{ if (a>c)
cout<<"The largest number is a="<<a<<endl;
else
cout<<"The largest number is c="<<c<<endl;
}
else
{ if (b>c)
cout<<"The largest number is b="<<b<<endl;
else
cout<<"The largest number is c="<<c<<endl;
}
cin.get();
getch();
}
Screen shot:
Program#3:
Q.Write a program to find all the roots of a quadratic equation ax2+bx+c=0.
Screen shot:
Programe#4:
Q.Write a program to find the Fibonacci series till term≤1000.
//fibonacci series
#include<iostream>
#include<conio.h>
using namespace std;
void main()
{
int fterm,sterm,temp;
fterm=0;
cout<<"Fibonacci series:"<<endl;
for (sterm=1;sterm<=1000;)
{
cout<<sterm<<" ";
temp=sterm+fterm;
fterm=sterm;
sterm=temp;
}
cout<<endl;
cin.get();
getch();
}
Screen shot: