Professional Documents
Culture Documents
11 OCTOBER 2011
Create file containing the program with a text editor. Run preprocessor to convert source file directives to source code program statements. Run compiler to convert source program into machine instructions (Object Code) Run linker to connect hardware-specific code to machine instructions, producing an executable file. Steps bd are often performed by a single command or button click. Errors detected at any step will prevent execution of following steps. 1-2
PROCESS STEPS
Source Code Object Code
Preprocessor
Modified Source Code
Linker
Executable Code
Compiler
1-3
ARITHMETIC OPERATORS
-5 13 - 4
2-4
ans
+
* / %
addition
subtraction multiplication division Modulus / remainder operator
ans = 7 + 3;
ans = 7 - 3; ans = 7 * 3; ans = 7 / 3; ans = 7 % 3; ans = 7 % 5;
10
4 21 2 1 2
2-5
2-6
CONSTANT VARIABLES
Constant Variables: variable whose content cannot be changed during program execution Used for representing constant values with descriptive names:
3-7
CLASS EXERCISE
Write a program to take two numbers and display their sum, product, division and remainder on the screen.
WORKING SOLUTION
#include<iostream.h> #include<conio.h> void main() { int num1, num2; cout<<"Enter Num1 "; cin>>num1; cout<<"Enter Num2 "; cin>>num2; cout<<"\n\nSum of numbers is "<<num1+num2; cout<<"\n\nProduct of numbers is "<<num1*num2; cout<<"\n\nDivision of numbers is "<<num1/num2; cout<<"\n\nRemainder of the numbers is "<<num1%num2; getch(); }