Showing posts with label AC.Printf and Scanf function. Show all posts
Showing posts with label AC.Printf and Scanf function. Show all posts

Printf Function


printf function is used to print information on screen. Note that c programming is a case sensitive. so you can not write "Printf".It is included in "stdio.h" Header file.

some examples if printf function:

printf(“This is printf function”);



printf(“\nI am a c programmer”);

Example program for printf:

#include<stdio.h>
#include<conio.h>
main()
{
         clrscr();
         printf("This is because of printf function");
         getch();
}

Scanf function

scanf function is used to gain data from user and store it into any variable.Note that Scanf(); is not allowed because c programming is a case-sensitive language.
Some examples of scanf function:
scanf(“%d”,&a);           // %d is data type of variable and a is the name of variable.
scanf(“%c”,&c);           // %c is a character datatype and c is a variable.
Example for scanf function.
#include<stdio.h>
#include<conio.h>
main()
{
            int a;
            clrscr();
            printf("Enter Number: ");
            scanf("%d",&a);
            printf("\nYou have entered %d",a);
            getch();
}