lab 1 getting started. creating a c program lab 1 : getting started login information user name:...
Post on 21-Dec-2015
216 views
TRANSCRIPT
![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](https://reader031.vdocuments.us/reader031/viewer/2022032704/56649d6c5503460f94a4b7d2/html5/thumbnails/1.jpg)
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](https://reader031.vdocuments.us/reader031/viewer/2022032704/56649d6c5503460f94a4b7d2/html5/thumbnails/2.jpg)
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](https://reader031.vdocuments.us/reader031/viewer/2022032704/56649d6c5503460f94a4b7d2/html5/thumbnails/3.jpg)
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](https://reader031.vdocuments.us/reader031/viewer/2022032704/56649d6c5503460f94a4b7d2/html5/thumbnails/4.jpg)
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](https://reader031.vdocuments.us/reader031/viewer/2022032704/56649d6c5503460f94a4b7d2/html5/thumbnails/5.jpg)
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](https://reader031.vdocuments.us/reader031/viewer/2022032704/56649d6c5503460f94a4b7d2/html5/thumbnails/6.jpg)
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](https://reader031.vdocuments.us/reader031/viewer/2022032704/56649d6c5503460f94a4b7d2/html5/thumbnails/7.jpg)
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](https://reader031.vdocuments.us/reader031/viewer/2022032704/56649d6c5503460f94a4b7d2/html5/thumbnails/8.jpg)
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](https://reader031.vdocuments.us/reader031/viewer/2022032704/56649d6c5503460f94a4b7d2/html5/thumbnails/9.jpg)
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](https://reader031.vdocuments.us/reader031/viewer/2022032704/56649d6c5503460f94a4b7d2/html5/thumbnails/10.jpg)
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](https://reader031.vdocuments.us/reader031/viewer/2022032704/56649d6c5503460f94a4b7d2/html5/thumbnails/11.jpg)
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](https://reader031.vdocuments.us/reader031/viewer/2022032704/56649d6c5503460f94a4b7d2/html5/thumbnails/12.jpg)
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](https://reader031.vdocuments.us/reader031/viewer/2022032704/56649d6c5503460f94a4b7d2/html5/thumbnails/13.jpg)
/* 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