C Input Output In Hindi

📔 : C 🔗

अभी तक दिए गए सभी example में आपने आपने देखा होगा कि printf() function में हमें variable की value print करने के लिए format specifiers pass करने होते थे , जो बताते हैं कि variable किस type का है।


C language में ये variable type के according कई सारे format specifiers हैं और इन्ही specifiers की help से हम user input और output process करते हैं। कुछ specifiers इस प्रकार है।

Data TypeFormat Specifier
int%d
char%c
float%f
double%lf
short int%hd
unsigned int%u
long int%li
long long int%lli
unsigned long int%lu
unsigned long long int%llu
signed char%c
unsigned char%c
long double%Lf

C Output

printf() function का use output print करने के लिए किया जाता है।

CopyFullscreenClose FullscreenRun
#include <stdio.h>
int main() {
  // DSimple string
  printf("Simple string");
  
  int testInteger = 5;
  printf("\nInterger Number : %d", testInteger);
  
  // float & double.
  float number1 = 13.5;
  double number2 = 12.4;
  printf("\nFloat : %f", number1);
  printf("\nDouble : %lf", number2);
  
  // character
  char chr = 'R';    
  printf("\nCharacter : %c", chr); 
  return 0;
}
Output
Simple string
Interger Number : 5
Float : 13.500000
Double : 12.400000
Character : R

C Input

C language में input लेने के लिए scanf() function का use किया जाता है। यह function stdio.h header files में ही define होता है। इसमें भी user input capture करते समय specifier के through हमें compiler को बताना पड़ता है कि user किस type की value को enter करेगा।

CopyFullscreenClose FullscreenRun
##include <stdio.h>
int main() {
    
  // character
  char chr;    
  printf("Enter any character : ");
  scanf("%c", &chr);
  
  int testInteger;
  printf("Enter integer value : ");
  scanf("%d", &testInteger);
 
  // float & double.
  float number1;
  double number2;
  printf("Enter float value : ");
  scanf("%f", &number1);
  printf("Enter double value : ");
  scanf("%lf", &number2);
  
  // now print values
  printf("\n\n-------------Entered Values---------------\n");
  printf("\nInterger Number : %d", testInteger);
  printf("\nFloat : %f", number1);
  printf("\nDouble : %lf", number2);
  printf("\nCharacter : %c", chr); 
  return 0;
}
Output
Enter any character : d
Enter integer value : 34
Enter float value : 34.34
Enter double value : 454.4545445
-------------Entered Values---------------

Interger Number : 34
Float : 34.340000
Double : 454.454544
Character : d

Related Topics :

Rahul Kumar

Rahul Kumar

Hi ! I'm Rahul Kumar Rajput founder of learnhindituts.com. I'm a software developer having more than 4 years of experience. I love to talk about programming as well as writing technical tutorials and blogs that can help to others. I'm here to help you navigate the coding cosmos and turn your ideas into reality, keep coding, keep learning :)

Get connected with me. :) LinkedIn Twitter Instagram Facebook

b2eprogrammers