Lab 03
Lab 03
LAB 03
Lab-4
Introduction to Programming
OBJECTIVE:
EQUIPMENT REQUIRED:
• Laptop
• Computer
TOOLS REQUIRED:
• DEV - C++
o int main()
This specifies the real beginning of our program. Here we are declaring a function named
main. All C++ programs must contain this function to be executable.
• C++ Statements
The statements of the program are written in curly braces. The curly brace {is called opening brace and}
is called closing brace. The braces are known as delimiters. These statements are collectively known as
body of a program.
#include <iostream>
Following are the building blocks that are used to build a C++ Program:
• numeric values
• variables
• declarations
• assignment
• identifiers
• reserved words
Data Types:
int: this key word is used to store integer values. It takes 2 to 4 bytes in memory float:
it is used to store real values. It takes 4 bytes in memory. char: it is used to store
character value. It takes 1 byte in memory.
Syntax:
int varname; int: C++
Keyword varname: Variable
identifier
; : Statement terminator
Variable declaration: the process of specifying variable name and its data type is called variable
declaration
Example of variable
declaration:
#include <iostream>
using namespace std;
int main() {
int x;
Variable Initialization: the process of assigning a value to a variable at the time of declaration is known as
variable initialization
#include <iostream>
using namespace std;
int main() {
int x=10;
cout << x << endl;
}
Exercises:
1. Write a program that performs all mathematical operations on two variables.
2. Write a program that inputs name, age and address from the user and then displays these values
on screen.
Rubric 1
02 Is not able to write the code in C++ and interpret it. Major help is required in
writing the program.
06 Can write and interpret C++ codes with minor error help.