Scanf, putchar(), getchar() function in C Programming - learnit

Home Top Ad

Post Top Ad

Saturday, May 15, 2021

Scanf, putchar(), getchar() function in C Programming

Scanf, putchar(), getchar() function in C Programming

Scanf, putchar(), getchar() function in C Programming

What is C Programming Langauge?

C is a general-purpose programming language that is extremely popular, simple, and flexible to use. A structured programming language is machine-independent and extensively used to write various applications, Operating Systems like Windows, and many other complex programs like Oracle database, Git, Python interpreter, and more.


History of C language

The base or father of programming languages is 'ALGOL.' It was first introduced in 1960. 'ALGOL' was used on a large basis in European countries. 'ALGOL' introduced the concept of structured programming to the developer community. In 1967, a new computer programming language was announced called as ‘BCPL’, which stands for Basic Combined Programming Language. BCPL was designed and developed by Martin Richards, especially for writing system software. This was the era of programming languages. Just after three years, in 1970 Ken Thompson that contained multiple features of ‘BCPL’ introduced a new programming language called ‘B’. This programming language was created using UNIX operating system at AT&T and Bell Laboratories. Both the 'BCPL' and 'B' were system-programming languages.


In 1972, a great computer scientist Dennis Ritchie created a new programming language called 'C' at the Bell Laboratories. It was created from 'ALGOL', 'BCPL' and 'B' programming languages. 'C' programming language contains all the features of these languages and many more additional concepts that make it unique from other languages.


'C' is a powerful programming language, which is strongly associated with the UNIX operating system. Even most of the UNIX operating system is coded in 'C'. Initially 'C' programming was limited to the UNIX operating system, but as it started spreading around the world, it became commercial, and many compilers were released for cross-platform systems. Today 'C' runs under a variety of operating systems and hardware platforms. As it started evolving, many different versions of the language were released. At times, it became difficult for the developers to keep up with the latest version as the systems were running under the older versions. To assure that 'C' language will remain standard, American National Standards Institute (ANSI) defined a commercial standard for 'C' language in 1989. Later, it was approved by the International Standards Organization (ISO) in 1990. 'C' programming language is also called as 'ANSI C'.


In C programming, scanf() is one of the commonly used function to take input from the user.
The scanf() function reads formatted input from the standard input such as keyboards.


putchar() function is a file handling function in C programming language which is used to write a character on standard output/screen.
getchar() function is used to get/read a character from keyboard input.


Function Description
putchar Declaration: int putchar(int char) putchar() function is used to write a character on standard output/screen. In a C program, we can use putchar function as below. putchar(char); where, char is a character variable/value.
getchar() Declaration: int getchar(void) getchar() function is used to get/read a character from keyboard input. In a C program, we can use getchar function as below. getchar(char); where, char is a character variable/value.

Example1

#include<stdio.h>
#include<conio.h>
Int main()
{
Int I;
Printf(“Please input Number);
Scanf(“%d”, &i);
}

Example 2

#include<stdio.h>
#include<conio.h>
int main()
{ char text[50];
printf("Please input User Name");
gets(text);
puts(text);
}


Please wtaching My Video is Below

No comments:

Post a Comment

Post Top Ad