Skip to main content

BASIC C FUNCTIONS || USING BASIC FUNCTIONS IN C || FUNCTIONS OF C-PROGRAMMING LANGUAGE

BASIC FUNCTIONS USED IN C-PROGRAMMING
​=========================================


(​TO WATCH IN VIDEO, CLICK HERE .)


​C-language is basically procedural programming language which highly depends on its functions and its use. Inspite of being case sensitive, C provides us the use of its pre-defined functions according to user choices.

​These functions are pre-defined under their respective header files.

​Before those functions, you should know about the scan formats that are used to input/output to/through a specific datatype.

​SCAN FORMAT          USED FOR

 %d                            Integer type (signed)
​%u                             Integer type(unsigned)
​%ld                            Long Integer type
​%c                              Char type(character by character)
​%s                              Char type(whole string at a time)
​%f                               Float type
​%lf                              Double type
​%Lf                             Long Double type



​SOME OF THE BASIC FUNCTIONS ARE
​==============================

1.) ​printf()

​HEADER FILE : <stdio.h>

​WORK : Prints messages that it contains.

​GENERAL SYNTAX:-
​printf("<MESSAGE OR OUTPUT SCAN FORMATS>");

​EXAMPLE1:-
​           printf("MESSAGE");//outputs messages that are in-between the double inverted commas(" ")
​OUTPUT: MESSAGE

​EXAMPLE2:-
​             int a=10;//variable a of int type initialised to 10
​printf("a= %d",a);
​OUTPUT:- a= 10

​EXAMPLE3:-
​int a=10;
​printf("a= %d",a);
​OUTPUT:- 10

​EXAMPLE4:-
​char c[3]="RAM";
​printf(c);// here c is providing the base address of the variable
​OUTPUT:- RAM



​2.) scanf()

​HEADER FILE : <stdio.h>

​WORK :  Inputs data to the variable assigned.

​GENERAL SYNTAX:-
​           scanf("<scan format> ",&variable_name);//inputs data to variable

​EXAMPLE1:-
​scanf("%d",&a);

​EXAMPLE2:-
​char b[5];//b variable of char type that can store data upto 5 characters
​scanf("%c",&b);

​We can assign multiple scan formats too.
​EXAMPLE3:-
​int a;
​char b[10];
​float c;
​scanf("%d %c %f",&a,&b,&c);


​3.) clrscr()

​HEADER FILE : <conio.h>

​WORK :  Clears the contents that are on the OUTPUT screen.

​GENERAL SYNTAX:-
​           clrscr();

​EXAMPLE:-
​   clrscr();


​4.) getch()

​HEADER FILE : <conio.h>

​WORK :  Inputs the first keystroke from keyboard.

​GENERAL SYNTAX:-
​           getch();//returns ASCII value of the keystroke to the integer type variable

​EXAMPLE:-
​ int a=getch();
​printf("a= %d",a);
​​OUTPUT:- 49 (keystroke from keyboard is 1)


​5.) gotoxy()

​HEADER FILE : <conio.h>

​WORK :  Positions cursor as specified.

​GENERAL SYNTAX:-
​           gotoxy(int x-axis, int y-axis);//positions the cursor coordinates asked accordingly

​EXAMPLE:-
​ printf("ITK");
​gotoxy(20,10);
​printf("ITKNOWLEDGE");


​OUTPUT:-


​Many more functions are there that you will face later on this site.

​                                                          Regards,
​                                                          ITK


Comments

Popular posts from this blog

ASCII TABLE || HEXADECIMAL TABLE

ASCII & Hexadecimal Table (CLICK THE IMAGE TO VIEW IT PROPERLY) REGARDS, ITK

Calculator Using C Programming

  C  is not only capable in maximizing the logical concept towards machine/software programming but it also makes users comfortable through its in-built functions. Making of simple calculator in C must at least be done by the novices themselves to improve and test their level of understandings in logics being applied. Here is the code that has been created for the joy of creativity through C-coding. CODE #include <stdio.h> #include <conio.h> int main() {     int a,b,result;     char ch[2]; clrscr(); gotoxy(30,1);printf("CALCULATOR"); gotoxy(10,8);printf("FIRST NUMBER : "); gotoxy(4,9);printf("OPERATION(+,-,*,/) : "); //to choose operation from gotoxy(9,10);printf("SECOND NUMBER : "); gotoxy(16,12);printf("RESULT : "); gotoxy(30,18);printf("Powered By : ITK"); gotoxy(25,8);scanf("%d",&a); // input first number gotoxy(25,9);scanf("%s",ch); //input operation as a...

KEYBOARD CHARACTERS || KEYBOARD CHARACTER NAMES || KEYBOARD SYMBOLS AND THEIR USES || KEYBOARD CHARACTERS NAMES

The symbols used in keyboards are generally not known to all of us about. Many of us don't know either their use or their names what they are called as too. Here is the list of the symbols that are in the computer keyboards with their names. Symbols in Keyboards and their names Sl.   No.                    Symbol                                  Name 1                      & ampersand or and 2                        ‘ apostrophe or single quote 3               ...