13
Lab 1 Getting Started

Lab 1 Getting Started. Creating a C program Lab 1 : Getting Started Login information User name: ge-208 Password: 111 Domain: ENG_MANAR Starting

  • View
    216

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Lab 1 Getting Started. Creating a C program Lab 1 : Getting Started Login information User name: ge-208 Password: 111 Domain: ENG_MANAR Starting

Lab 1

Getting Started

Page 2: Lab 1 Getting Started. Creating a C program Lab 1 : Getting Started Login information User name: ge-208 Password: 111 Domain: ENG_MANAR Starting

Creating a C program

Page 3: Lab 1 Getting Started. Creating a C program Lab 1 : Getting Started Login information User name: ge-208 Password: 111 Domain: ENG_MANAR Starting

Creating a C program

Page 4: Lab 1 Getting Started. Creating a C program Lab 1 : Getting Started Login information User name: ge-208 Password: 111 Domain: ENG_MANAR Starting

Creating a C program

Page 5: Lab 1 Getting Started. Creating a C program Lab 1 : Getting Started Login information User name: ge-208 Password: 111 Domain: ENG_MANAR Starting

Lab 1 : Getting Started

Login information User name: ge-208 Password: 111 Domain: ENG_MANAR

Starting the compiler Go to Start > Program Files >

Microsoft Visual Studio 6.0 > Microsoft Visual C++ 6.0

Page 6: Lab 1 Getting Started. Creating a C program Lab 1 : Getting Started Login information User name: ge-208 Password: 111 Domain: ENG_MANAR Starting

Writing a C program

Choose File > New Go to Files tab, then

choose Text File Type lab1daytime.c

in the filename field Choose C:\Documents

and Settings\ge-208\ in the save file location field.

Page 7: Lab 1 Getting Started. Creating a C program Lab 1 : Getting Started Login information User name: ge-208 Password: 111 Domain: ENG_MANAR Starting

General C Program

#include <stdio.h>

void main(void){

}

Write program hereWrite program here

preprocessor directive

primary function (main)

Page 8: Lab 1 Getting Started. Creating a C program Lab 1 : Getting Started Login information User name: ge-208 Password: 111 Domain: ENG_MANAR Starting

printf() Instruction

printf(printf("format_string""format_string", , argument_listargument_list));;

Prints what is written between the quotation marks on screen

Escape sequences are used to control output formatting

Page 9: Lab 1 Getting Started. Creating a C program Lab 1 : Getting Started Login information User name: ge-208 Password: 111 Domain: ENG_MANAR Starting

Escape Sequences

\a Alert/bell \b Backspace \n New line \r Carriage

return \t Tab

Page 10: Lab 1 Getting Started. Creating a C program Lab 1 : Getting Started Login information User name: ge-208 Password: 111 Domain: ENG_MANAR Starting

printf() Example

printf("This is line1\n");printf("This");printf(" is ");printf(“line2\nline3\n");

This is line1This is line2line3

Page 11: Lab 1 Getting Started. Creating a C program Lab 1 : Getting Started Login information User name: ge-208 Password: 111 Domain: ENG_MANAR Starting

Comments

Long comments can be inserted in a C program by placing them between /* */Example: /* This is a long comment in C-

programming */

Short comments in the same line can be written after //Example: printf(“\n"); //insert new line

Page 12: Lab 1 Getting Started. Creating a C program Lab 1 : Getting Started Login information User name: ge-208 Password: 111 Domain: ENG_MANAR Starting

Compilation Errors

If there are any errors in your program, the compiler will indicate the line number of the error along with an explanation.

See the bottom window to check the compiler’s output!!

Page 13: Lab 1 Getting Started. Creating a C program Lab 1 : Getting Started Login information User name: ge-208 Password: 111 Domain: ENG_MANAR Starting

/* Write your name, student number and comments here */#include <stdio.h>Void main(void){ Printf(“Welcome to”);Printf(“GE 208 Lab!\n”); Printf(“This line should give a beep!\a\n”); Printf(“This\tline\tis tabbed\n”); Printf(“This” “is” “another” “printf\n”); Printf(“One\”); Printf(“line\n”);Printf(“This should not appear\r where did the text go?\n”);Printf(“Where is the ‘C’ in ABC\b?\n”);Printf(“If you want to print \\, \\n, \” or %% on the screen\n”);}

Examples