1 / 9

String

String. #include&lt;stdio.h&gt; #include&lt;conio.h&gt; void main( ) { char *ch1 = &quot;Hello, I am being shown using Pointer&quot;; char ch2[ ]= &quot;Hello, I am being shown using Array&quot; ; printf(&quot;<br>%s <br><br>%s&quot;, ch1, ch2); }. #include&lt;stdio.h&gt; #include&lt;conio.h&gt; void main( ) { int n;

finian
Télécharger la présentation

String

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. String

  2. #include<stdio.h> #include<conio.h> void main( ) { char *ch1 = "Hello, I am being shown using Pointer"; char ch2[ ]= "Hello, I am being shown using Array" ; printf("\n%s \n\n%s", ch1, ch2); }

  3. #include<stdio.h> #include<conio.h> void main( ) { int n; char *city[5]={"Dhaka", "Sylhet", "Rajshahi", "Khulna", "Chittagong"}; for (n=0 ; n<5 ; n++) printf("\nCity name[%d] is %s", n, city[n]); }

  4. puts( ) #include<stdio.h> #include<conio.h> void main( ) { char *ch1 = "Hello, I am being shown using Pointer"; char ch2[ ]= "Hello, I am being shown using Array" ; puts(ch1); puts(ch2); }

  5. scanf( ) #include<stdio.h> #include<conio.h> void main ( ) { char name[30]; int age; printf("\n What is your name??:"); scanf("%s", name); printf("\nNow what is your age??:"); scanf("%d", &age); if (age<=0) printf("\nSorry %s, Age cannot be negetive", name); if (age>0 && age<=20) printf("\nOh %s, You are just a kid",name); else printf("\nHmm %s,You seem to be old", name); }

  6. gets( ) #include<stdio.h> #include<conio.h> void main ( ) { char name[30]; int age; printf("\n What is your name??:"); gets(name); printf("\nNow what is your age??:"); scanf("%d", &age); if (age<=0) printf("\nSorry %s, Age cannot be negetive", name); if (age>0 && age<=20) printf("\nOh %s, You are just a kid",name); else printf("\nHmm %s,You seem to be old", name); }

  7. Working with strings

  8. #include<stdio.h> #include<conio.h> #include<string.h> void main ( ) { char name1[30], name2[40] ; int x ; printf("\nEnter the first string:") ; gets(name1); printf("Enter the second string:") ; gets(name2); x= strcmp (name1, name2); if(x!=0) printf("\n\nTwo strings that you have entered are not equal"); else printf("\n\nTwo strings are equal"); }

  9. #include<stdio.h> #include<conio.h> #include<string.h void main ( ) { char name1[30], name2[40]; int x,y ; printf("\nEnter the first string in lower case:"); gets(name1); printf("\nEnter the second string in Upper Case:"); gets(name2); strupr(name1); strlwr(name2); printf("\nHere is your first string converted into upper case:") ; puts(name1); printf("\nHere is your second string converted into lower case:") ; puts(name2); }

More Related