Now lets look at few fairly simple examples. Let us read an input from user and show what the user has entered in the next line
For Integer
#include<stdio.h>
#include<conio.h>
void main()
{
int entered;
printf("Enter An Integer :")
scanf("%d",&entered);
printf("\n The Entered Integer Is %d",entered);
getch();
}
For Floating
#include<stdio.h>
#include<conio.h>
void main()
{
float entered;
printf("Enter An Floating Number :")
scanf("%f",&entered);
printf("\n The Entered Float Is %f",entered);
getch();
}
For Character
#include<stdio.h>
#include<conio.h>
void main()
{
char entered;
printf("Enter An Character :")
scanf("%c",&entered);
printf("\n The Entered Character Is %c",entered);
getch();
}
Try these out & also try to read two or more variables in a single scanf statement .Like reading and an integer and a floating in the same program and displaying both at once. We will look at this in the next post.....
For Integer
#include<stdio.h>
#include<conio.h>
void main()
{
int entered;
printf("Enter An Integer :")
scanf("%d",&entered);
printf("\n The Entered Integer Is %d",entered);
getch();
}
For Floating
#include<stdio.h>
#include<conio.h>
void main()
{
float entered;
printf("Enter An Floating Number :")
scanf("%f",&entered);
printf("\n The Entered Float Is %f",entered);
getch();
}
For Character
#include<stdio.h>
#include<conio.h>
void main()
{
char entered;
printf("Enter An Character :")
scanf("%c",&entered);
printf("\n The Entered Character Is %c",entered);
getch();
}
Try these out & also try to read two or more variables in a single scanf statement .Like reading and an integer and a floating in the same program and displaying both at once. We will look at this in the next post.....