100 likes | 284 Views
String. #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("<br>%s <br><br>%s", ch1, ch2); }. #include<stdio.h> #include<conio.h> void main( ) { int n;
E N D
#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); }
#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]); }
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); }
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); }
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); }
#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"); }
#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); }