C Tutorials
- What is C?
- History Of C?
- Feature of C?
- How to Install C?
- How to write c program?
- First c program
- Flow of C program
- printf() and scanf() in C
- C Program Structure
- Variables in C
- Data Types in C
- Keywords in C
- C Operators
- Comments in C
- Escape Sequence in C
- Escape Sequence in C
- Constants in C
- C - Storage Classes
- C - Decision Making
- Switch statement in C
- C Loops
- Loop Control Statements
- Type Casting in C
- functions in C
- call by value Or call by reference
- Recursion in C
- Storage Classes in C
- Array
- String
- Pointer
- Pointer And Array
- Pointer with function
- Structure
- Union
- File Handling
- Preprocessor Directives
Important Links
Home » First c program »
First c program
File name : eligible.c
#include<stdio.h>
int main()
{
int num;
printf("Enter your age: ");
scanf("%d", &num);
if (num <18)
{
printf("you are not eligible for voting");
}
else
{
printf("You can vote!!");
}
return 0;
}
Output :-
Enter your age:25 You can vote!!
include header file :-
The first line of the program #include is a preprocessor command, which tells a C compiler to include stdio.h file before going to actual compilation.
C program depends upon some header files for function definition. That are used in program. each header file by default is extended with '.h'. The file should be included using #include.
Eg.
C program depends upon some header files for function definition. That are used in program. each header file by default is extended with '.h'. The file should be included using #include.
Eg.
#include<stdio.h>
All the definintions and prototypes of function defined in this file are available in the current program.#include<conio.h>
conio.h is a C header file used mostly by MS-DOS compilers to provide console input/output. It is not part of the C standard library or ISO C, nor is it defined by POSIX. This header declares several useful library functions for performing "console input and output" from a program.