0% found this document useful (0 votes)
26 views44 pages

Section 1

Uploaded by

Sayed Younis
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)
26 views44 pages

Section 1

Uploaded by

Sayed Younis
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/ 44

Introduction to

Programming
Using C#

By 2024-2025

Eng. Omar Islam Lab1


Introduction to Programming

• Subject Objectives
– Understand the Basics of Structure Programming.
– Fundamentals of Programming in C#
• Programming language types.
• Translators.
• Error types.
Part I

• Introduction to programming
• Visual studio GUI
• Basic lines of Code
Why Programming?
• Automation:
Example: Automated online checkout systems in stores save time and reduce errors.
• Innovation(new technologies):
Example: Companies like Tesla use programming to develop advanced self-driving technology.
• Problem Solving:
Example: Programmers develop apps that help users manage their health, such as fitness trackers
that monitor physical activity.
• Data Handling:
Example: Social media platforms like Facebook analyze user data to suggest friends and
content, enhancing user experience.
• Building Technology:
Example: Websites like YouTube rely on programming to create, upload, and stream videos
efficiently.
Why Programming?
Cont.

Applications of Programming
• Healthcare: Used in medical devices and patient records.
• Finance: Powers banking systems and online transactions.
• Education: Enhances learning through online platforms.
• Entertainment: Creates video games and movies.
• Transportation: Important for traffic management and self-
driving cars.
What is a computer?
Software Definition

• A sequence of ordered instructions written to


perform a specific task
• These ordered instructions are called: Code
• Example: Whatsapp send button
Programming Languages
Programming Language types

• High Level
• Intermediate (Assembly)
• Low Level (0/1)

• We Will be using C# as a programming


language for this course.
Compilers/Interpreters

• Compilers and interpreters take human-


readable code and convert it to machine
code.
Compilers

• Definition: A compiler translates the entire


source code of a programming language into
machine code or intermediate code at once.
This process happens before the program is
run, creating an executable file.
• Faster since the entire code is translated
beforehand
Interpreters

• Definition: An interpreter translates the source


code line by line and executes it immediately.
• Easier debugging since errors are found
immediately as the code is run.
Which is better?

• There is no better.
• For performance-critical applications, compilers
are often preferred due to faster execution times.

• For rapid development or scripting, interpreters are


more beneficial because they allow for immediate
execution and testing.( Web Applications)
Error types

• Syntax Error.
• Semantic Error.
• Runtime Error.
Syntax Error
• Syntax is like Grammar rules in English Language.
Example: "She go to school yesterday.“

• Syntax errors in programming occur when the rules


of the programming language are violated.
Syntax Error Cont.

• Console.WriteLine("Hello World"
• When you run this code it will result in Syntax Error
due to the missing )

• When does it occur: These errors are detected during


compilation
Semantic Error

• Semantics refers to the meaning of a sentence or


code.
Example: "The cat drove the car to the supermarket.“

Grammatically, the sentence is correct (syntax), but the


meaning is illogical
Semantic Error Cont.

• In code Semantic errors happen which the program


produces undesired output.

• Example: Making a program that adds two numbers


but the result is the multiplication.
Runtime Error

• Runtime errors happen during the execution of


the program

Example:
• Dividing by zero.
• Reading from a file that doesn’t exist.
What is C#

• It is a modern, high-level programming language


developed by Microsoft in 2000.
• Fact: It is one of the most widely-used languages in
the world and powers everything from desktop
applications to video games!
Why C#?

• Powerful: C# can build apps of any size—whether for small


devices or large systems.
• Easy to Learn: Its syntax is clean and simple, making it
beginner-friendly for new programmers.
• Versatile: Used for desktop apps, web apps, cloud computing,
mobile apps, and even game development with Unity.
• Strongly Typed: Reduces errors by ensuring data types are
defined and handled carefully.
Requirements of C# Program

• Editor: Writing the source code


• Debugger: Detects Bugs
• Compiler: Translates Code
• .Net Framework: developer platform with tools and
libraries for building any type of app
Where to write my code?

• Integrated Development Environment (IDE)

• We will be using Visual Studio:


– Add Code
– Modify Code
– Run Code
– Debugging
Installation

• https://visualstudio.microsoft.com/downloads/

• Download the community version.


• Follow the steps of the download.
In this part just choose this
option and continue to finish your
setup
Visual Studio GUI
Visual Studio GUI
Visual Studio GUI
Visual Studio GUI
Visual Studio GUI
Visual Studio GUI 2022
Visual Studio GUI 2019
Visual Studio GUI 2019
Current Default Class: Program

Entry Point: Main Method

Current Namespace

Curly Braces {} we use


them whenever we
want to define a code
segment: the start and
end of a series of
statements

Console Class
WriteLine Method
What is Console

• Console: is class is used to represent the


standard input (ReadLine),
output(Write,WriteLine), and error streams for
the console applications

Console Class

Calling a function on Console Class


Some basic lines of code

• Console.Write();
• Console.WriteLine( );
• Console.ReadLine();
• Console.ReadKey();
Code with me

• Write your name


• Your age
• Your collage
• Each in a separate line
Skipping Characters

• They are typically introduced with a backslash


(\) followed by a specific character (n,t,a,\\,b)
that has a special meaning.
• These are useful for formatting and controlling
the way strings are displayed or processed.
Skipping Characters

• \n: causing the text that follows it to appear on


the next line.
• \t : Creating a gap in the text.
• \\: Represents a literal backslash character.

• Try \a
Practice 1:

• Write the following statements in the editor


and answer what will be the output:
• Console.Write("***\n ");
• Console.Write("***");
• Console.ReadKey();
Practice 2

• Modify the previous code so it outputs the


following:
*****
****
***
**
*
Practice 3

• Modify the code to print the following shape


using only a sequence of Console.WriteLine()
statement.
*********
*******
*****
***
*
Thank You

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy