C programming में input (keyboard से)/output (screen पर) के लिए हम printf और scanf function का उपयोग करते है, और दूसरे function भी है जिनका उपयोग काम ही किया जाता है ज्यादातर ये दोनों function ही उपयोग किये जाते है।

c programming में input के लिए scanf function का use किया जाता है। इस function से input लेने के लिए निचे दिए गए syntax को follow करना होगा।

Syntax

// taking input
scanf("%format_specifier", &variable);

यहाँ पर format specifier में हमें %d(Integer के लिए) %f(Float के लिए) %c(Character के लिए) आदि दे सकते है। different input/ouput

के लिए हम एक निश्चित format specifier का उपयोग करते है। जो की निचे table में दिये गए है –

Format SpecifierType
%cCharacter
%dSigned integer
%fFloat values
%iUnsigned integer
%l or %ld or %liLong
%lfDouble
%LfLong double
%luUnsigned int or unsigned long
%lli or %lldLong long
%lluUnsigned long long
%oOctal representation
%sString
%uUnsigned int
%x or %XHexadecimal representation

Taking Input

#include <stdio.h>

int main() {
    // declare
    int n;

    // input
    scanf("%d", &n);
}

यहाँ पर integer value input लेने के लिए एक वेरिएबल n declare किया है, और scanf में %d लिखा है, क्योकि हम integer value इनपुट लेना चाहते है, & (address of operator) ये n वेरिएबल का address देने के उपयोग किया है, कीबोर्ड द्वारा जो भी integer value आएगी वो वेरिएबल n में store हो जाएगी।

Display Output

ऊपर दिए गए उदाहरण में n को input लिया था उसके display और console screen पर display करने के लिए निचे दिए गए उदाहरण का अनुशरण करे -
  
  
#include <stdio.h>
int main() {
    // declare
    int n;

    // input
    scanf("%d", &n);

    // ouptut
    printf("%d", n);

    return 0;
}

Leave a Reply

Your email address will not be published. Required fields are marked *