0% found this document useful (0 votes)
6 views

Syntax and Datatypes

Uploaded by

sheikhnayamul123
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Syntax and Datatypes

Uploaded by

sheikhnayamul123
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

High School Programming

Lecture: 03
WELCOME TO

Mahinur Rahaman Hridoy


BSc in CSE, Diploma
Software Developer
Recap Previous Lecture
How to do programming using Mobile Phone?
How to do programming using Computer?
Write your first program
Agenda
C# Introduction
Types of application
Program structure, syntax, and comments
Datatypes
Variables
C# Programming Language
❑ C# is pronounced “C-Sharp”
❑ It is an object-oriented programming language created by Microsoft that runs
on the .NET Framework.
❑ C# has roots from the C family, and the language is close to other popular
languages like C++ and Java.
❑ The first version was released in year 2002. The latest version, C# 11, was
released in November 2022.
Why Use C#?
❑ It is one of the most popular programming language in the world
❑ It is easy to learn and simple to use
❑ It has a huge community support
❑ C# is an object oriented language which gives a clear structure to programs
and allows code to be reused, lowering development costs Fig: C-Sharp
❑ As C# is close to C, C++ and Java, it makes it easy for programmers to switch
to C# or vice versa
Types of applications

1. Console Application
2. Web Application
3. Android Application
4. Windows Application
Basic Structure and Syntax

namespace FirstConsoleApp
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(“Hello World”);
}
}
}
Comments
-- Comments can be used to explain C# code, and to make it more readable. It
can also be used to prevent execution when testing alternative code.

Single-line Comments:
Single-line comments start with two forward slashes (//).

Example:
// This is a comment
Console.WriteLine("Hello World!");

C# Multi-line Comments:
-- Multi-line comments start with /* and ends with */.

Example: Fig: Comment


/* The code below will print the words Hello World
to the screen, and it is amazing */
Console.WriteLine("Hello World!");
Datatypes
-- The Datatypes are something that gives information about

1. The Size of the memory location.


2. The Range of data that can be stored inside that memory location
3. Possible Legal Operations that can be performed on that memory location.
4. What Types of Results come out from an expression when these types are used inside that expression?

Data Type Size Description


int 4 bytes Stores whole numbers from -2,147,483,648 to 2,147,483,647
long 8 bytes Stores whole numbers from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
float 4 bytes Stores fractional numbers. Sufficient for storing 6 to 7 decimal digits
double 8 bytes Stores fractional numbers. Sufficient for storing 15 decimal digits
bool 1 bit Stores true or false values
char 2 bytes Stores a single character/letter, surrounded by single quotes
string 2 bpc Stores a sequence of characters, surrounded by double quotes
Variables
-- Variables are containers for storing data values.

SYNTAX: data_type variable_name;


EXAMPLE: int age; float gpa;

Rules for variable declaration in C#:


✓ A variable name must begin with a letter or underscore.
✓ Variables in C# are case sensitive
✓ They can be constructed with digits and letters.
✓ No special symbols are allowed other than underscores.
✓ sum, Height, _value, and abc123, etc. are some examples of the
variable name
Contact Me

Phone Website Mail Facebook


+8801321869515 www.mrhridoy.me mrhridoy.me@gmail.com Mahinur Rahaman Hridoy

Thank You

You might also like