BIL104E_w10 - BIL104E INTRODUCTION TO SCIENTIFIC AND...

Info iconThis preview shows pages 1–9. 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; }
Background image of page 5

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

View Full DocumentRight Arrow Icon
Application Write a program for a given string from standard input. Use scanf to obtain string. Every string elements will write separately. S T I R G N S \0 0 1 3 2 5 4 6 7 49
Background image of page 6
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; }
Background image of page 7

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

View Full DocumentRight Arrow Icon
String Operations Copy (assignment) Compare Find length Combine I/O
Background image of page 8
Image of page 9
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 / 24

BIL104E_w10 - BIL104E INTRODUCTION TO SCIENTIFIC AND...

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

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