Professional Documents
Culture Documents
Computer Programming
Computer Programming
Computer Programming
BsCs (1st B)
COMPUTER
PROGRAMMING
Submitted to: Prof. Sohail Mumtaz
b) Binary Operators
c) Header Files
d) Compiler & Interpreter
Int
Short
Shortint
Long
Unsinged char
Unsinged int
Unsinged long
Unsinged short
b) binary operations :
Operator
Name
Comma
!=
Inequality
Modulus
%=
Modulus/assignment
&
Bitwise AND
&&
Logical AND
&=
Bitwise AND/assignment
Multiplication
*=
Multiplication/assignment
Addition
+=
Addition/assignment
Subtraction
Subtraction/assignment
>
Member selection
>*
Pointer-to-member selection
Division
/=
Division/assignment
<
Less than
<<
Left shift
<<=
Left shift/assignment
<=
Assignment
==
Equality
>
Greater than
>=
>>
Right shift
>>=
Right shift/assignment
Exclusive OR
^=
Exclusive OR/assignment
Bitwise inclusive OR
|=
||
Logical OR
c) Header Files:
stdio.h
math.h
conio.h
graphics.h
iostreem.h
string.h
Interpreter :
An interpreter is a program that converts one statement of a
program at one time. It executes this statements before
translating the next statement of the source program. If there
is an error in the statements, the interpreter stops working
and displays an error messages.
// series of 2
#include <iostream>
#include <conio.h>
using namespace std;
int main()
{
int a;
a=2;
while (a<=1024)
{
cout<< "\t " << a;
a=a+1;
}
getch ();
return 0;
}
#include<iostream>
#include<conio.h>
using namespace std;
int factorial(int n);
int main()
{
int n;
cout<< "Enter a positive integer: ";
cin>> n;
cout<< "Factorial of " << n << " = " << factorial(n);
getch();
return 0;
}
int factorial(int n)
{
if(n!=1)
return n*factorial(n-1);
}
#include <iostream>
#include <conio.h>
#include <cmath>
int main()
{
inta,b;
long p;
cout<< "enter any number " <<endl;
cin>> b;
p=pow(2,b);
cout<< "power" << p;
getch();
return 0;
}
#include <iostream>
#include <conio.h>
#include <cmath>
int main()
{
intx,y;
long p;
cout<< "Enter a value " <<endl;
cin>> x;
cout<< "Enter a power " <<endl;
cin>> y;
p=pow(x,y);
cout<< "Answer " << p;
getch();
return 0;
}
#include <iostream>
#include <conio.h>
int main()
{
int a;
a=7;
while (a<=150)
{
if (a%7==0)
{
cout<< a << "\t" ;
}
a=a+1;
}
getch();
return 0;
}
#include <iostream>
#include <conio.h>
int main()
{
int a;
a=1;
while (a<=100)
{
if (a%2==1)
{
cout<< a << "\t" ;
}
a=a+1;
}
getch();
return 0;
}
#include <iostream>
#include <conio.h>
int main()
{
int a;
a=7;
while (a<=150)
{
if (a%7==0)
{
cout<< a << "\t" ;
}
a=a+1;
}
getch();
return 0;
}
#include <iostream>
#include <conio.h>
using namespace std;
int main()
{
inta,b,c;
cout<< "Enter age of Ali" <<endl;
cin>> a;
cout<< "Enter age of Asad" <<endl;
cin>> b;
cout<< "Enter age of Fakhir" <<endl;
cin>> c;
if (a>b)
{
if (b>c)
{
cout<< "Fakhir is youngest among all" <<endl;
}
}
else if (c>b)
{
if (b>a)
{
cout<< "Ali is youngest among all" <<endl;
}
}
else
if (a&&c>b)
{
cout<< "Asad is youngest among all" <<endl;
}
getch();
return 0;
}
#include <iostream>
#include <conio.h>
using namespace std;
int main()
{
longintinput_seconds;
int days, hours, minutes, seconds;
getch();
return 0;
}
#include <iostream>
#include <conio.h>
using namespace std;
int main()
{
long a;
intx,v,y,z;
cout<< "Enter x" <<endl;
cin>> x;
cout<< "Enter v" <<endl;
cin>> v;
cout<< "Enter y" <<endl;
cin>> y;
cout<< "Enter z" <<endl;
cin>> z;
a=(x*x*x)*(v*v)+x*(y*y*y)+x*y*(z*z);