Skip to main content

C programming

Include stdio.h header file in your program.
C programming is small and cannot do much by itself. You need to use libraries that are necessary to run the program. The stdio.h is a header file and C compiler knows the location of that file. To use the file, you need to include it in your program using #include preprocessor.
Why do you need stdio.h file in this program?
In this program, we have used printf() function which displays the text inside the quotation mark. Since printf() is defined in stdio.h, you need to include stdio.h.
The main() function
In C programming, the code execution begins from the start of main() function (doesn’t matter if main() isn’t located at the beginning).
The code inside the curly braces { } is the body of main() function. The main() function is mandatory in every C program.
int main() {
}
This program doesn’t do anything but, it’s a valid C program.
The printf() function
The printf() is a library function that sends formatted output to the screen (displays the string inside the quotation mark). Notice the semicolon at the end of the statement.
In our program, it displays Hello, World! on the screen.
Remember, you need to include stdio.h file in your program for this to work.
The return statement
The return statement return 0; inside the main() function ends the program. This statement isn’t mandatory. However, it’s considered good programming practice to use it.

Comments

Popular posts from this blog

C – Data Types

C data types are defined as the data storage format that a variable can store a data to perform a specific operation. Data types are used to define a variable before to use in a program. Size of variable, constant and array are determined by data types. C – data types: There are four data types in C language. They are, Types Data Types Basic data types int, char, float, double Enumeration data type enum Derived data type pointer, array, structure, union Void data type void 1. Basic data types in C language: 1.1. Integer data type: Integer data type allows a variable to store numeric values. “int” keyword is used to refer integer data type. The storage size of int data type is 2 or 4 or 8 byte. It varies depend upon the processor in the CPU that we use.  If we are using 16 bit processor, 2 byte  (16 bit) of memory will be allocated for int dat...

Write a program to do the following operations:

6. Write a program to do the following operations: --Read any two positive integer operands (say op1 & op2) and one character                type operator (say opr). Note that opr is any mathematical operator. --Depending upon the operator, do the appropriate operation. e.g. if opr is '+'                 then the display the value obtained by evaluating the expression (op1 + op2) #include<stdio.h> #include<conio.h> void main() {         int a,b;         char n;         clrscr(); printf(“enter the value of a and b=”);         scanf(“%d%d”,&a,&b);         printf(“enter the operation to perform=”); ...

C – Programming Basics

If you are looking for C programs, please click here “C programs”. This C programming basics section explains a simple “Hello World” C program. Also, it covers below basic topics as well, which are to be known by any C programmer before writing a C program. C programming basic commands to write a C program A simple C program with output and explanation Steps to write C programs and get the output Creation, Compilation and Execution of a C program * How to install C compiler and IDE tool to run C programming codes Basic structure of a C program * Example C program to compare all the sections * Description for each section of the C program C programs ( Click here for more C programs )  with definition and output – C program for Prime number, Factorial, Fibonacci series, Palindrome, Swapping 2 numbers with and without temp variable, sample calculator program and sam...