w10 - BIL104E INTRODUCTION TO SCIENTIFIC AND ENGINEERING...

Info iconThis preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon
BIL104E INTRODUCTION TO SCIENTIFIC AND ENGINEERING COMPUTING (C) WEEK – 10
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
DIFFERENCE? Characters & Strings
Background image of page 2
Characters and Strings? Character constants (literals): single quotes „a‟, „A‟, „0‟, „1‟, „ \ n‟, „ ‟, „I‟, „ \ 0‟ String constants (literals): double quotes “The weather is rainy” “The answer is %.2f. \ n”
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
What is strings? Strings are stored in char arrays. The end of the string is marked with a special character, the null character , which is simply the character with the value 0 (or \0 ). Example: Char array [50]=„STRINGS‟ S T I R G N S \0 0 1 3 2 5 4 6 7 49
Background image of page 4
Example Program #include<stdio.h> int main() { char name[30]; printf ( “ Enter Name: "); scanf( "%s", name ); printf ( “ Entered Name: %s\n", name ); return 0; } Enter Name: bil104e Entered Name: bil104e
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Example Program #include<stdio.h> int main() { char name[30]; int i; printf("Enter Name: "); scanf( "%s" , name ); printf("Entered Name: "); for( i = 0; name[i]!='\0'; i++ ) printf(" %c" , name[i] ); printf("\n"); return 0; } Enter Name: bil104e Entered Name: bil104e
Background image of page 6
String Operations Copy (assignment) Compare Find length Combine I/O
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/22/2010 for the course BIL 104 taught by Professor Abc during the Fall '09 term at Istanbul Technical University.

Page1 / 19

w10 - BIL104E INTRODUCTION TO SCIENTIFIC AND ENGINEERING...

This preview shows document pages 1 - 8. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online