C-Programming introduction
Every C-Program begins with a function called "main()",A function is simply a collection of commands that do "something". From main, we can call other functions, whether they be written by us or by others or use built-in language features.To access the standard functions that comes with your compiler, you need to include a header with the #include directive.
Let's look a simple C-program:
The #include is a "preprocessor" directive that tells the compiler to put code from the header called stdio.h into our program before actually creating the executable file. By including header files, you can get access to many different functions like printf() and getchar() functions, these are included in stdio.h.
The "int main() " tells the compiler that there is a function named main, and that the function returns an integer. The "curly braces" ("{" & "}") indicates the beginning and end of functions and other code blocks.
The printf function is the standard C way of displaying output on the screen. The statements with in the quotes tell the compiler what you want to print in output screen
Q) W.A Program to Display "Hello, World!"
Let's look a simple C-program:
PROGRAMME#include <stdio.h>
int main()
{
printf( "I am alive! Beware.\n" );
getchar();
return 0;
}
int main()
{
printf( "I am alive! Beware.\n" );
getchar();
return 0;
}
OUTPUTI am alive! Beware.
The #include is a "preprocessor" directive that tells the compiler to put code from the header called stdio.h into our program before actually creating the executable file. By including header files, you can get access to many different functions like printf() and getchar() functions, these are included in stdio.h.
The "int main() " tells the compiler that there is a function named main, and that the function returns an integer. The "curly braces" ("{" & "}") indicates the beginning and end of functions and other code blocks.
The printf function is the standard C way of displaying output on the screen. The statements with in the quotes tell the compiler what you want to print in output screen
Q) W.A Program to Display "Hello, World!"
PROGRAMME
#include <stdio.h>
int main()
{
printf("Hello, World!"); // printf() displays the string inside quotation
return 0;
}
OUTPUT
Hello, World!
Hello, World!
Comments
Post a Comment