JOIN us on
WhatsApp Group Join Now
Telegram Join Join Now

हिंदी माध्यम नोट्स

Categories: C Language in hindi

Input or Output Operation : getchar ( ) , Putchar , Scanf function , printf () in hindi in c language

getchar ( ) , Putchar , Scanf function , printf () in hindi in c language क्या है हिंदी में c भाषा में जाने |
Input or Output Operation : किसी C प्रोग्राम मे तीन operation मुख्य होते है :-(i) Reading (ii) Processing(iii) Writing .और इस article मे हम C प्रोग्राम के input और आउटपुट commands को स्टडी करेगे |
किसी ब्व्ही कंप्यूटर language मे,दो तरीके से data को input करा सकता है |
(1) Assigment Operator
(2)Scan function
सभी higher level कंप्यूटर language की तरह C language मे, input और output statement को प्रोग्रामर नहीं बना सकता है | इसके लिए Pre define function को call करना पड़ता है |Print function और स्कैन function standard input output library मे store होता है  |
किसी data को read और write करने के लिए निम्न function को यूज़ किया जाता है :-

1. getchar ( )

किसी भी character को पढने  के लिए scanf के अलावा getchar() का use किया जाता है |इसकी header file stdio.h होती है|इसका syntax है :-
variable name = getchar();
variable name का datatype char होना चाहिए |जब ये syntax run होगा ,तब कंप्यूटर तब तक wait करेगा जब तक कोई key press नहीं होती है |जब कोई key press होगी तब कोम्प्लिएर यूजर द्वारा दिए गये charter को getchar() को assign कर देगा |
उदहारण के लिए :
#include <conio.h>
#include <Stdio.h>
void main ()
{
char variable_name ;
printf(“Please enter charter”);
variable_name=getchar();
printf(“%c”,variable_name);
getch();
}
आउटपुट होगा :-
Please enter charter G
G

2.Putchar ()

putchar() का उपयोग किसी charter को console screen या file मे रखने या डिस्प्ले के लिए किया जाता है |इसकी header file भी stdio.h है |इसका syntax है :-
putchar( variable name);
इसमें variable_name उस variable का नाम है जिसमे data store है |
उदहारण के लिए:
#include <conio.h>
#include <Stdio.h>
void main ()
{
char variable_name ;
printf(“Please enter charter”);
variable_name=getchar();
putchar (variable_name);
getch();
}
आउटपुट होगा :
Please enter charter P
P

3. Scanf function :

Scanf () function को हम पहले भी basic methodology of c languag मे पढ़ चुके है | किन्तु अभी हम कुछ advance methodology के बारे मे पढेगे| Scanf का syntax है :-
scanf(“data type identifier”, address of variable);
अगेर प्रोग्रामर character data को a variable के address पर सेव करना चाहता है तब scanf() statement होगा :-
scanf(“%c”,&a);
यहा पर %c charter का data identifier है और &a  का मतलब है variable a का address |
जब किसी प्रोग्राम मे एक से अधिक data को Read करना है तब उसका syntax होगा :-
scanf(“date type identifier 1 date type identifier 2 ………”,addressr of variables);
अगर प्रोग्रामर दो datas (integer type) और (float type) को variable a और b के address पर store करना चाहता है तब:
scanf(” %d %f”,&a,&b) ;
इसमें %d और %f integer और float data type के data indentifier है |और &a और &b ,a और b के address है |
Data identifier की लिस्ट निम्न है :-
S.No
Data
Indentifier
Datatype
1
%d
Integer
2
%c
Character
3
%e
Floating Value
In Exponation
4
%f
Floating Value
5
%h
Short Integer
6
%i
Octal,Hexdecimal
Integer
7
%o
Octal Integer
8
%s
String
9
%u
Unsigned
Integer
10
%x
Hexa Decimal

4. Format Input :

C प्रोग्राम मे data को formatting की सुविधा है |इसमें scanf function से ,प्रोग्रामर ये देसिड़े कर सकता है की c complier कितने डिजिट (Number) या charterer( String) करेगे |इसका syntax है :-
integer के लिए :
scanf(“% width d”,address);
width: डिजिट की सख्या जिसे complier read करेगे |
float के लिए:
scanf(“%width f”,address);
width : डिजिट की सख्या जो decimal के बाद read होगी |
उदहारण के लिए :
#include <conio.h>
#include<stdio.h>
void main ()
{
float a,b;
int c,d;
pritnf(“Please Enter four numbers”);
scanf(“%2d %4d %7f %6f”,&c,&d,&a,&b);
printf(“Integer 1=%d”,c);
printf(“Integer 2=%d”,d);
printf(“Decimal 1=%f”,a);
printf(“Decimal 2=%f”,b);
}
आउटपुट होगा :
Please Enter four numbers 2589 3456 123.98765443 5.897
Integer 1 = 25
Integer 2 = 3456
Decimal 1=123.9876544
Decimal 2=5.897000
इस उदहारण मे , पहले integer की width 2 होने के कारण कंप्यूटर कवेल दो हो डिजिट को read कर पाया |
दूसरा integer की width 4 है इसलिए ये 4 डिजिट को read करेगा |
पहले float मे , decimal के बाद 7 डिजिट को read करेगा तभी 7 digits read ही होगा |
दुसरे float मे , width मे 6 है और डेसीमल के बाद डिजिट 3 है इसलिए  इसमें तीन जीरो आ जाते है |

printf ()

printf () function मे data formating scanf () function की तरह होता है |इसका उदहारण  है|
#include <conio.h>
#include<stdio.h>
void main ()
{
float a,b;
int c,d;
pritnf(“Please Enter four numbers”);
scanf(“%d %d %f %f”,&c,&d,&a,&b);
printf(“Integer 1=%2d”,c);
printf(“Integer 2=%4d”,d);
printf(“Decimal 1=%5f”,a);
printf(“Decimal 2=%7f”,b);
}
आउटपुट होगा :
Please Enter four numbers 25 49 145.846572 8956.647326145629047
Integer 1 = 25
Integer 2 = 4900
Decimal 1=145.84657
Decimal 2=8956.6473261
Sbistudy

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…

2 weeks ago

Translation in english grammer in hindi examples Step of Translation (अनुवाद के चरण)

Translation 1. Step of Translation (अनुवाद के चरण) • मूल वाक्य का पता करना और उसकी…

2 weeks ago

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…

2 weeks ago

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…

2 weeks ago

विश्व के महाद्वीप की भौगोलिक विशेषताएँ continents of the world and their countries in hindi features

continents of the world and their countries in hindi features विश्व के महाद्वीप की भौगोलिक…

2 weeks ago

भारत के वन्य जीव राष्ट्रीय उद्यान list in hin hindi IAS UPSC

भारत के वन्य जीव भारत में जलवायु की दृष्टि से काफी विविधता पाई जाती है,…

2 weeks ago
All Rights ReservedView Non-AMP Version
X

Headline

You can control the ways in which we improve and personalize your experience. Please choose whether you wish to allow the following:

Privacy Settings
JOIN us on
WhatsApp Group Join Now
Telegram Join Join Now