हिंदी माध्यम नोट्स
String : Functions in c computer language definition in hindi स्ट्रिंग क्या है c भाषा में कंप्यूटर हिंदी में
किसी character को integer मे चगे करने के लिए प्रोग्राम है |
#include<conio.h>
#include<stdio.h>
void main()
{
char a=’b’;
printf(“Asiic value of b is %d”,a);
getch();
}आउटपुट होगा :
Asiic value of b is 98किसी character पर arithmetic operation भी perform कर सकते है | Arithmetic operation मे character की ASIIC value के साथ कैलकुलेशन होती है |जैसे :#include<conio.h>
#include<stdio.h>
void main()
{
char a=’b’;
char y;
y=’a’+1;
printf(“Asiic value of b is %d”,a);
printf(“%c”,y)
printf(“Asiic value of b is %d”,y);
getch();
}
इस उदहारण मे , b की ASIIC value 98 है, y=’a’+1; statement से y की ASIIC value 98+1=99 हो जाएगी |printf(“%c”,y) से 99 ASIIC value वाला character print होगा |
आउटपुट होगा :
Asiic value of b is 98
c
Asiic value of b is 99
1.atoi() function
इस function से किसी digits के string को integer को convert कर सकते है |जैसे
#include<conio.h>
#include<stdio.h>
void main()
{
char a=’2019′;
int b;
b=atoi(a);
printf(“%d”,b);
getch();
}
इस उदाहारण मे ‘2019’ जो की एक string है b=atoi(a); statement से integer मे convert हो गयी जो की integer variable b मे store हो जाती है |
ओउपुत होगा :
2019
String Comparison :
#include<stdio.h>
void main()
{
char a[10],b[10];
int i;
printf(“enter your string 1”);
gets(a);
printf(“enter your string 2”);
gets(b);
if(strcmp(a,b)==1)
{
printf(“Strings are not same .”);
}
else
{printf(“Strings are same .”);
getch();
}
string_name 1,string_name 2 दो charter array होती है |जब strcat () function execute होगा string_name 2 ,string_name 1 के बाद write होगा |string_name 1 मे null charter को डिलीट करके string_name 2 को insert किया जाता है |
और string_name 1 की size इतनी होनी चाहिए की string_name 2 के chartercet insert हो जाये |
उदहारण के लिए :
#include<conio.h>
#include<stdio.h>
void main()
{
char a[15],b[10];
printf(“enter your string 1”);
gets(a);
printf(“enter your string 2”);
gets(b);
strcat(a,b);
printf(“%s”,a);
getch(();
}
आउटपुट होगा :
इस function से दो strings को ही नहीं string constant को भी add कर सकते है |उदाहरण के लिए:
#include<conio.h>
#include<stdio.h>
void main()
{
char a[15],b[10];
printf(“enter your string 1”);
gets(a);
strcat(a,Hello!);
printf(“%s”,a);
getch(();
}
ओउपुत होगा :
enter your string 1 Parth
ParthHello!
String Copy :
String copy function strcpy() का use किसी string को दुसरे string मे copy करने के लिए किया जाता है |इसका syntax है :-
strcpy(string_name 1,string_name 2);
और string_name 1 की size इतनी होनी चाहिए की string_name 2 के charterer,string_name 1 मे copy हो जाये |उदहारण के लिए:
#include<conio.h>
#include<stdio.h>
void main()
{
char a[15],b[10];
printf(“enter your string 1”);
gets(a);
printf(“Before Coping=%s”,a);
printf(“enter your string 2”);
gets(b);
strcpy(a,b);
printf(“After Coping=%s”,a);
getch(();
}
आउटपुट होगा :
String Length:
#include<stdio.h>
void main()
{
char a[15];
printf(“enter your string “);
gets(a);
int length;
length=strlen(a);
printf(“Size of string=%d”,length);
getch();
}आउटपुट होगा :
enter your string Parth
Size of string=5इसके next article मे इस अभी function को for loop और pre define function के अलावा प्रोग्राम को discuss करेगे |
Recent Posts
Question Tag Definition in english with examples upsc ssc ias state pcs exames important topic
Question Tag Definition • A question tag is a small question at the end of a…
Translation in english grammer in hindi examples Step of Translation (अनुवाद के चरण)
Translation 1. Step of Translation (अनुवाद के चरण) • मूल वाक्य का पता करना और उसकी…
Report Writing examples in english grammer How to Write Reports explain Exercise
Report Writing • How to Write Reports • Just as no definite rules can be laid down…
Letter writing ,types and their examples in english grammer upsc state pcs class 12 10th
Letter writing • Introduction • Letter writing is an intricate task as it demands meticulous attention, still…
विश्व के महाद्वीप की भौगोलिक विशेषताएँ continents of the world and their countries in hindi features
continents of the world and their countries in hindi features विश्व के महाद्वीप की भौगोलिक…
भारत के वन्य जीव राष्ट्रीय उद्यान list in hin hindi IAS UPSC
भारत के वन्य जीव भारत में जलवायु की दृष्टि से काफी विविधता पाई जाती है,…