Tutorial #5 Summer 2005. while x = -2; while (x < 0) { printf("x is still negative :(\n"); x++; } printf("x is no longer negative.\n");

Slides:



Advertisements
Similar presentations
Recursive Descent Technique CMSC 331. UMBC 2 The Header /* This program matches the following A -> B { '|' B } B -> C { '&' C } C -> D { '^' D } D ->
Advertisements

Enumeration Data Type enum Day {SUN, MON, TUE, WED, THU, FRI, SAT}; Day today; today = WED; if (today == FRI) cout
ENUMERATED, typedef. ENUMERATED DATA TYPES An enumeration consists of a set of named integer constants. An enumeration type declaration gives the name.
Line Efficiency     Percentage Month Today’s Date
Tutorial #6 Summer functions ( parameters list ) { body }
21 August (B.V.Patel institute of BMC & IT) STRUCTURE AND UNIONS.
Programs Day 1 and 2. Write a Program to: 1: Read in two numbers and output the largest 2: Read in an exam mark and output the appropriate grade according.
CPT: Types/ Computer Programming Techniques Semester 1, 1998 Objective of these slides: –to look at how new types can be created 6. User-defined.
CS 1430: Programming in C++.
ProjectImpactResourcesDeadlineResourcesDeadline Forecast Plan Time Resources Risk 001xx 002xx 003xx 004xx 005xx 006xx 007xx TotalXX Example 1: Portfolio.
MayJunJulAugSepOctNovDec2016 Milestone 1 May 10 Milestone 2 Jun 7 Milestone 3 Jul 21 Milestone 4 Aug 12 Milestone 5 Sep 20 Milestone 6 Oct 30 Milestone.
What do I need to Know For My Assignment?. C Pointer Review To declare a pointer, we use the * operator. This is similar to but different from using *
Arrays Name, Index, Address. Arrays – Declaration and Initialization int x; y[0] y[1] y[2]
Tutorial #4 Summer 2005.
Jan 2016 Solar Lunar Data.

Primary Longman Elect 3A Chapter 5 Asking about dates.
Payroll Calendar Fiscal Year
Q1 Jan Feb Mar ENTER TEXT HERE Notes


Project timeline # 3 Step # 3 is about x, y and z # 2
Average Monthly Temperature and Rainfall

MON TUE WED THU
GANTT CHARTS Example Text Text Here Text Here Text Here Text Here

Mammoth Caves National Park, Kentucky
2017 Jan Sun Mon Tue Wed Thu Fri Sat


Gantt Chart Enter Year Here Activities Jan Feb Mar Apr May Jun Jul Aug
Q1 Q2 Q3 Q4 PRODUCT ROADMAP TITLE Roadmap Tagline MILESTONE MILESTONE
Free PPT Diagrams : ALLPPT.com


Calendar Year 2009 Insure Oklahoma Total & Projected Enrollment
MONTH CYCLE BEGINS CYCLE ENDS DUE TO FINANCE JUL /2/2015
Jan Sun Mon Tue Wed Thu Fri Sat
CSC215 Homework Homework 03 Due date: Oct 07, 2016.
2008 Calendar.
©G Dear 2008 – Not to be sold/Free to use
Sun Mon Tue Wed Thu Fri Sat
Electricity Cost and Use – FY 2016 and FY 2017
CS 240 – Lecture 7 Boolean Operations, Increment and Decrement Operators, Constant Types, enum Types, Precedence.
ENTANGLEMENTS REPORTED

Sun Mon Tue Wed Thu Fri Sat
Text for section 1 1 Text for section 2 2 Text for section 3 3
Text for section 1 1 Text for section 2 2 Text for section 3 3
Text for section 1 1 Text for section 2 2 Text for section 3 3
Text for section 1 1 Text for section 2 2 Text for section 3 3
Q1 Q2 Q3 Q4 PRODUCT ROADMAP TITLE Roadmap Tagline MILESTONE MILESTONE
Free PPT Diagrams : ALLPPT.com

Text for section 1 1 Text for section 2 2 Text for section 3 3
1/○~1/○ weekly schedule MON TUE WED THU FRI SAT SUN MEMO
Text for section 1 1 Text for section 2 2 Text for section 3 3
Text for section 1 1 Text for section 2 2 Text for section 3 3
Text for section 1 1 Text for section 2 2 Text for section 3 3
2016 | 10 OCT SUN MON TUE WED THU FRI SAT
Text for section 1 1 Text for section 2 2 Text for section 3 3
Sun Mon Tue Wed Thu Fri Sat
Text for section 1 1 Text for section 2 2 Text for section 3 3
Project timeline # 3 Step # 3 is about x, y and z # 2
TIMELINE NAME OF PROJECT Today 2016 Jan Feb Mar Apr May Jun

SEESIM 14 Timeline Jan Feb Mar Apr May Jun Jul Aug Sep Oct
Q1 Q2 Q3 Q4 PRODUCT ROADMAP TITLE Roadmap Tagline MILESTONE MILESTONE
2008 Calendar.
Presentation transcript:

Tutorial #5 Summer 2005

while x = -2; while (x < 0) { printf("x is still negative :(\n"); x++; } printf("x is no longer negative.\n");

For Loop #include int main() { int secs; for (secs = 2; secs > 0; secs--) printf(“%d seconds!\n”, secs); printf(“The End!”); return 0 ; }

While Loop #include int main() { char ch; ch = getchar(); while (ch == ‘ ‘ || ch == ‘\n’) ch = getchar(); return 0; }

Do While Loop #include int main() { char ch; do { ch = getchar(); } while (ch == ‘ ‘ || ch == ‘\n’) ; return 0; }

While loops double age; printf("enter your age: "); scanf("%lf", &age); while (age < 18) { printf("Invalid age, please try again: "); scanf("%lf", &age); } printf("Welcome to C-Stuff.com, the"); printf("#1 adult site on the web!\n");

break #include int main( void ) { int count; char ch; while ((ch = getchar()) != ‘\n’) { if (ch == ‘\t’) break; putchar(ch); } printf(“After the loop”); return 0 ; }

break #include int main( void ) { int i,j; char ch; for(i = 0; i < 9; ++i) { for (j = 0; j < i; ++j) { scanf(“%c”, &ch); if (ch == ‘ ‘) break; } printf(“After the j loop”); } printf(“After the i loop”); return 0 ; }

break #include int main( void ) { int count; char ch; while ((ch = getchar()) != ‘\n’ && ch != ‘\t’) { putchar(ch); } return 0 ; }

Continue #include int main( void ) { int count = 0; char ch; while (count < 10) { ch = getchar(); if (ch == ‘\n’) continue; putchar(ch); count++; } return 0 ; }

Continue #include int main( void ) { int count = 0; char ch; while (count < 10) { ch = getchar(); if (ch != ‘\n’) { putchar(ch); count++; } return 0 ; }

Continue #include int main( void ) { int count; char ch; for (count = 0; count < 10; ++count) { ch = getchar(); if (ch == ‘\n’) continue; putchar(ch); } return 0 ; }

Continue #include int main( void ) { int count; char ch; for (count = 0; count < 10; ++count) { ch = getchar(); if (ch != ‘\n’) putchar(ch); } return 0 ; }

Continue #include int main( void ) { int i; for (i = 0; i < 100; i += 2) if (i % 3 == 0 || i % 7 == 0) continue; else printf("%d ", i); return 0 ; }

Continue #include int main( void ) { int i; for (i = 0; i < 100; i += 2) if (i % 3 != 0 && i % 7 != 0) printf("%d ", i); return 0 ; }

enum #include int main( void ) { enum month {JAN = 1, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC}; enum color {GREEN = 1, RED, BLUE = 7, YELLOW}; enum animals {MONKEY, FISH, DOG, CAT, HORSE, NUM_ANIMALS}; return 0 ; }

enum #include enum day {SUN, MON, TUE, WED, THU, FRI, SAT}; int main( void ) { int cnt; for (cnt = SUN) ; cnt <= SAT); cnt++) { switch (cnt) { case SUN: printf("Sunday"); break; case MON: printf("Monday"); break; case Tue: printf("Tuesday"); break; case WED: printf("Wednesday"); break; case THU: printf("Thursday"); break; case FRI: printf("Friday"); break; case SAT: printf("Saturday"); break; default: printf("ERROR!"); } return 0; }

Arrays #include #define N 10 int main() { int arr[N]; for (i = 0; i < N; ++i) arr[i] = i; return 0; }

Arrays #include #define N 10 int main() { double b[] = {1.5, 3.0, 5.7}; char c[] = {`a`, `b`, `c`, `d`, `e`}; int a[10] = {1, 5, 7}; … return 0; }

Arrays #include #define N 10 int main() { int arr[N] = {0}; … return 0; }

Arrays #include #define N 5 int main() { char arr[N]; int i; for (i = 0; i < N; ++i) scanf(“%c”, &a[i]);... return 0; }

Arrays – Find the errors #include int main() { int arr[2] = {1,2,3,4}; … return 0 ; }

Arrays – Find the errors #include int main() { int n = 3; int arr[n] = {1,2,3}; int i; for (i = 1; i <= n; ++i) printf(“%d\n”, arr[i++]); return 0 ; }