A SIMPLE CALCULATOR CODE FOR C++

CALCULATOR CODE


#include <iostream>
#include <math.h>
using namespace std;
int main ()
{
char ans='y';
while (ans=='y' || ans== 'Y')
{
float a,b,c,d;
double pi=3.14159265;
cout<<"                      <<@ Calculator By Hashmat naqvi @>>"<<endl;
cout<<" Press 1 for Addition"<<endl;
cout<<" Press 2 for Subtrection"<<endl;
cout<<" Press 3 for Division"<<endl;
cout<<" Press 4 for Multiplication"<<endl;
cout<<" Press 5 for Square"<<endl;
cout<<" Press 6 for Compairing Numbers"<<endl;
cout<<" Press 7 for Grades Calculator"<<endl;
cout<<" Press 8 for Cube"<<endl;
cout<<" Press 9 For Square Root"<<endl;
cout<<" press 0 For Exit"<<endl;
cout<<" Enter Your Choice : ";
cin>>c;
if (c==1)
{
cout<<"                                  ADDITION:"<<endl;
cout<<" Enter 1st Number:"<<endl;
cin>>a;
cout<<" Enter 2nd Number:"<<endl;
cin>>b;
cout<<" Result Is:"<<a+b<<endl;
}
else if (c==2)
{
cout<<"                                 SUBRRECTION:"<<endl;
cout<<" Enter 1st Number:"<<endl;
cin>>a;
cout<<" Enter 2nd Number:"<<endl;
cin>>b;
cout<<" Result Is:"<<a-b<<endl;
}
else if (c==3)
{
cout<<"                                  DIVISION:"<<endl;
cout<<" Enter 1st Number:"<<endl;
cin>>a;
cout<<" Enter 2nd Number:"<<endl;
cin>>b;
cout<<" Result Is:"<<a/b<<endl;
}
else if (c==4)
{
cout<<"                                MULTIPLICATION:"<<endl;
cout<<" Enter 1nd Number:"<<endl;
cin>>a;
cout<<" Enter 2nd Number:"<<endl;
cin>>b;
cout<<" Result Is:"<<a*b<<endl;
}
else if (c==5)
{
cout<<"                                    SQUARE:"<<endl;
cout<<" Enter Number:"<<endl;
cin>>a;
cout<<" Result is:"<<a*a<<endl;
}
else if (c==6)
{
cout<<"                              COMPAIRING NUMBERS"<<endl;
cout<<" Enter 1st Number:"<<endl;
   cin>>a;
   cout<<" Enter 2nd Number:"<<endl;
cin>>b;
cout<<" Enter 3rd Number:"<<endl;
cin>>d;
if (a>b&&a>d)
{
cout<<" 1st Number Is Greater"<<endl;
}
else if (b>a&&b>d)
{
cout<<" 2nd Number Is Greater"<<endl;
}
else
{
cout<<" 3rd Number Is Greater"<<endl;
}
}
else if (c==7)
{
cout<<"                               GRADES CALCULATOR"<<endl;
cout<<" Enter your Marks Percentage:"<<endl;
cin>>a;
if (a<60)
{
   cout<<" You are Fail : Work Hard & Try Again"<<endl;
}
   else if (a<68)
{
   cout<<" You get C : Work Hard"<<endl;
}
   else if (a<76)
{
   cout<<" You Get C+ : Good"<<endl;
}
   else if (a<83)
{
   cout<<" You Get B : V.Good"<<endl;
}
   else if (a<89)
{
   cout<<" You Get B+ : Great"<<endl;
}
   else if (a<=100)
{
   cout<<" You Get A : Excellent"<<endl;
}
   else

{
   cout<<" INVALID INPUT"<<endl;
}
}
else if (c==8)
{
cout<<"                                     CUBE"<<endl;
cout<<" Enter Number"<<endl;
cin>>a;
cout<<" Result="<<a*a*a<<endl;
}
else if (c==9)
{
cout<<"                                  SQUARE ROOT"<<endl;
cout<<" Enter Number"<<endl;
cin>>a;
cout<<" Result is="<<sqrt (a)<<endl;
}
else if (c==0)
{
cout<<"                                   Bye Bye"<<endl;
}

else
{
cout<<" INVALID INPUT"<<endl;
}
{
cout<<"                        THANKS FOR USING MY CALCULATOR"<<endl;
cout<<"                                 See You Soon"<<endl;
}
cout<<"Do YOu want to Continue or recalculate Yes(Y),No (N)";
        cin>>ans;
}
system ("pause");
return 0;
}

Cache Memory

What is Cache Memory ?


cache memory, also called Cache,  a supplementary memory system that temporarily stores frequently used instructions and data for quicker processing by the central processor of acomputer. The cache augments, and is an extension of, a computer’s main memory. Both main memory and cache are internal, random-access memories (RAMs) that use semiconductor-based transistor circuits. Cache holds a copy of only the most frequently used information or program codes stored in the main memory; the smaller capacity of the cache reduces the time required to locate data within it and provide it to the computer for processing.
When a computer’s central processor accesses its internal memory, it first checks to see if the information it needs is stored in the cache. If it is, the cache returns the data to the processor. If the information is not in the cache, the processor retrieves it from the main memory. Disk cache memory operates similarly, but the cache is used to hold data that has been recently written on, or retrieved from, a magnetic disk or other external storage device.

Computer Main Memory And Its Types


Computer Memory

MEMORY IS THE INTERNAL STORAGE AREA OF THE COMPUTER. MEMORY IDENTIFIES THE DATA STORAGE.THE PHYSICAL MEMORY USUALLY REFERRED TO US MAIN MEMORY OR RAM.


TYPES OF MEMORY

  • RAM

  • ROM

RAM

RAM STANDS FOR RANDOM ACCESS MEMORY.IT WRITE DATA INTO RAM AND ASLO READ DATA FROM RAM. RAM IS A VOLATILE MEMORY.IT HOLDS DATA AS LONG AS THE COMPUTER IS SWITCHED ON.THERE ARE TWO TYPES OF RAM

  • DRAM

  • SRAM

  • DRDRAM

DRAM

DRAM STANDS FOR DYNAMIC RANDOM ACCESS MEMORY. MOSTLY USED IN PERSONAL COMPUTERS.DRAM MUST HAVE ELECTRIC CURRENT TO MAINTAIN ELECTRICAL STATE(REFRESH).ITS ACCESS TIME IS 60 - 70 NAN0SEC0NDS.


SRAM

SRAM STANDS FOR STATIC RANDOM ACCESS MEMORY.ITS ACCESS TIME LESS THAN 60 NAN0SECONDS.


DRDRAM

DRDRAM STANDS FOR DIRECT RAMBUS DYNAMIC RANDOM ACCESS MEMORY.IT IS THE NEW TYPE OF RAM. IT ACCESS TIME 20 TIMES FASTER THAN DRAM.


ROM

ROM STANDS FOR READ ONLY MEMORY.IT IS A NON-VOLATILE MEMORY.IT READ DATA FROM MEMORY.

TYPES OF ROM

  • PROM

  • EPROM

PROM

PROM STANDS FOR PROGRAMMABLE READ ONLY MEMORY. IT ACTS LIKE A ROM. THERE ARE TWO TYPES OF PROMS.

  • EPROM

  • EEPROM

EPROM(ERASABLE)

EPROM STANDS FOR ERASABLE PROGRAMMABLE READ ONLY MEMORY. IT CAN BE ERASED AND REPROGRAMMED BY THE USER.


EEPROM(NON ERASABLE):

EEPROM STANDS FOR ELECTRICALLY ERASABLE PROGRAMMABLE READ ONLY MEMORY.NONERASABLE PROMS CANNOT BE CHANGED ONCE THEY ARE PROGRAMMED.

Operating system architecture




The computer architecture of a computing system defines its attributes as seen by the programs that are executed in that system, that is, the conceptual structure and functional behavior of the machine hardware. Then, the computer architect defines the functions to be executed in the hardware and the protocol to be used by the software in order to exploit such functions. Note that the architecture has nothing to do with the organization of the data flow, the logical design, the physical design, and the performance of any particular implementation in the hardware.
      Hence By Architecture we mean the order in which certain hardware Processes are carried out by the OS and has nothing to do with the logical software flow of the Computer.

Simple view

An Operating System is the layer between the hardware and software, as in
 
 

An Operating System is responsible for the following functions
  • Device management using device drivers
  • Process management using processes and threads
  • Inter-process communication
  • Memory management
  • File systems
In addition, all operating systems come with a set of standard utilities. The utilities allow common tasks to be performed such as
  • being able to start and stop processes
  • being able to organise the set of available applications
  • organise files into sets such as directories
  • view files and sets of files
  • edit files
  • rename, copy, delete files
  • communicate between processes

Kernel

The kernel of an operating system is the part responsible for all other operations. When a computer boots up, it goes through some initialisation functions, such as checking memory. It then loads the kernel and switches control to it. The kernel then starts up all the processes needed to communiate with the user and the rest of the environment (e.g. the LAN)
The kernel is always loaded into memory, and kernel functions always run, handling processes, memory, files and devices.
The traditional structure of a kernel is a layered system, such as Unix. In this, all layers are part of the kernel, and each layer can talk to only a few other layers. Application programs and utilities live above the kernel.
The Unix kernel looks like Unix kernel
Most of the Operating Systems being built now use instead a micro kernel, which minimises the size of the kernel. Many traditional services are made into user level services. Communication being services is often by an explicit message passingmechanism.
The major micro-kernel Operating System is Mach. Many others use the concepts of Mach.Mach kernel
Some systems, such as Windows NT use a mixed approach NT kernel

Operating Systems


Operating system ABCs
Operating system boxAn operating system or OS is a software program that enables the computer hardware to communicate and operate with the computersoftware. Without a computer operating system, a computer and software programs would be useless. In the picture to the right, is an example of Microsoft Windows XP, a popular operating system and what the box may look like if you were to visit a local retail store to purchase it.
Operating system types
As computers have progressed and developed so have the operating systems. Below is a basic list of the different operating systems and a few examples of operating systems that fall into each of the categories. Many computer operating systems will fall into more than one of the below categories.
GUI - Short for Graphical User Interface, a GUI Operating System contains graphics and icons and is commonly navigated by using a computer mouse. See the GUI definition for a complete definition. Below are some examples of GUI Operating Systems.
Multi-user - A multi-user operating system allows for multiple users to use the same computer at the same time and different times. See themulti-user definition for a complete definition for a complete definition. Below are some examples of multi-user operating systems.
Multiprocessing - An operating system capable of supporting and utilizing more than one computer processor. Below are some examples of multiprocessing operating systems.
Multitasking - An operating system that is capable of allowing multiple software processes to run at the same time. Below are some examples of multitasking operating systems.
Multithreading - Operating systems that allow different parts of a software program to run concurrently. Operating systems that would fall into this category are:

Operating system listing
Below is a listing of many of the different operating systems available today, the dates they were released, the platforms they have been developed for and who developed them.
Operating systemDate first releasedPlatformDeveloper
AIX and AIXLUnix and Linux history.VariousIBM
AmigaOSCurrently no AmigaOS history.AmigaCommodore
AndroidNovember 5, 2007MobileGoogle
BSDUnix and Linux history.VariousBSD
Caldera LinuxUnix and Linux history.VariousSCO
Corel LinuxUnix and Linux history.VariousCorel
Debian LinuxUnix and Linux history.VariousGNU
DUnixUnix and Linux history.VariousDigital
DYNIX/ptxUnix and Linux history.VariousIBM
HP-UXUnix and Linux history.VariousHewlett Packard
iOS2010MobileApple
IRIXUnix and Linux history.VariousSGI
Kondara LinuxUnix and Linux history.VariousKondara
LinuxUnix and Linux history.VariousLinus Torvalds
MAC OS 8Apple operating system history.Apple MacintoshApple
MAC OS 9Apple operating system history.Apple MacintoshApple
MAC OS 10Apple operating system history.Apple MacintoshApple
MAC OS XApple operating system history.Apple MacintoshApple
Mandrake LinuxUnix and Linux history.VariousMandrake
MINIXUnix and Linux history.VariousMINIX
MS-DOS 1.xMS-DOS history.IBMMicrosoft
MS-DOS 2.xMS-DOS history.IBMMicrosoft
MS-DOS 3.xMS-DOS history.IBMMicrosoft
MS-DOS 4.xMS-DOS history.IBMMicrosoft
MS-DOS 5.xMS-DOS history.IBMMicrosoft
MS-DOS 6.xMS-DOS history.IBMMicrosoft
NEXTSTEPApple operating system history.VariousApple
OS/21987IBMIBM
OSF/1Unix and Linux history.VariousOSF
QNXUnix and Linux history.VariousQNX
Red Hat LinuxUnix and Linux history.VariousRed Hat
SCOUnix and Linux history.VariousSCO
Slackware LinuxUnix and Linux history.VariousSlackware
Sun SolarisUnix and Linux history.VariousSun
SuSE LinuxUnix and Linux history.VariousSuSE
System 1Apple operating system history.Apple MacintoshApple
System 2Apple operating system history.Apple MacintoshApple
System 3Apple operating system history.Apple MacintoshApple
System 4Apple operating system history.Apple MacintoshApple
System 6Apple operating system history.Apple MacintoshApple
System 7Apple operating system history.Apple MacintoshApple
System VUnix and Linux history.VariousSystem V
Tru64 UnixUnix and Linux history.VariousDigital
TurbolinuxUnix and Linux history.VariousTurbolinux
UltrixUnix and Linux history.VariousUltrix
UnisysUnix and Linux history.VariousUnisys
UnixUnix and Linux history.VariousBell labs
UnixWareUnix and Linux history.VariousUnixWare
VectorLinuxUnix and Linux history.VariousVectorLinux
Windows 2000Microsoft Windows history.IBMMicrosoft
Windows 2003Microsoft Windows history.IBMMicrosoft
Windows 3.XMicrosoft Windows history.IBMMicrosoft
Windows 8Microsoft Windows history.IBMMicrosoft
Windows 7Microsoft Windows history.IBMMicrosoft
Windows 95Microsoft Windows history.IBMMicrosoft
Windows 98Microsoft Windows history.IBMMicrosoft
Windows CEMicrosoft Windows history.PDAMicrosoft
Windows MEMicrosoft Windows history.IBMMicrosoft
Windows NTMicrosoft Windows history.IBMMicrosoft
Windows VistaMicrosoft Windows history.IBMMicrosoft
Windows XPMicrosoft Windows history.IBMMicrosoft
XenixUnix and Linux history.VariousMicrosoft