Download presentation
Presentation is loading. Please wait.
1
CSE 1321 - Module 1 A Programming Primer
4/5/2019 CSE 1321 Module 1
2
Ps Skeletons BEGIN MAIN END MAIN
Note: every time you BEGIN something, you must END it! Write them as pairs! 4/5/2019 CSE 1321 Module 1
3
Skeletons using System; class MainClass {
public static void Main (string[] args) { } Point out the beginning and end Note: The opening “{“ means BEGIN and the closing “}” means END 4/5/2019 CSE 1321 Module 1
4
Ps Printing BEGIN MAIN PRINT “Hello, World!”
PRINT “Bob” + “ was” + “ here” END MAIN Point out the beginning and end Ps 4/5/2019 CSE 1321 Module 1
5
Printing using System; class MainClass {
public static void Main (string[] args) { Console.WriteLine ("Hello, World!"); Console.WriteLine ("Bob"+" was"+" here"); } Note: There’s also a Console.Write() 4/5/2019 CSE 1321 Module 1
6
Declaring/Assigning Variables
BEGIN MAIN CREATE userName CREATE studentGPA userName ← “Bob” studentGPA ← 1.2 END MAIN userName “Bob” studentGPA 1.2 Ps 4/5/2019 CSE 1321 Module 1
7
Declaring/Assigning Variables
using System; class MainClass { public static void Main (string[] args) { string userName; float gpa; userName = "Bob"; gpa = 1.2f; } 4/5/2019 CSE 1321 Module 1
8
Reading Text from the User
BEGIN MAIN CREATE userInput PRINT “Please enter your name” READ userInput PRINT “Hello, ” + userInput END MAIN Ps 4/5/2019 CSE 1321 Module 1
9
Reading Text from the User
using System; class MainClass { public static void Main (string[] args) { string userInput; Console.Write("Please enter your name: "); userInput = Console.ReadLine(); Console.WriteLine("Hello, "+userInput); } 4/5/2019 CSE 1321 Module 1
10
Reading Numbers from the User
BEGIN MAIN CREATE userInput PRINT “Please enter your age: ” READ userInput PRINT “You are ” + userInput + “ years old.” END MAIN Ps 4/5/2019 CSE 1321 Module 1
11
Reading Numbers from the User
using System; class MainClass { public static void Main (string[] args) { string userInput; Console.Write("Please enter your age: "); userInput = Console.ReadLine(); int age = Convert.ToInt32(userInput); Console.WriteLine("You are "+age+" years old."); } 4/5/2019 CSE 1321 Module 1
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.