Introduction
Programming is a tool to perform various computations with the help of a machine. There are numerous programming languages(coding language) based on need and machine on which program will execute.
Data Types
In our childhood we learned mathematical numbers and the English alphabet(Data Types).
In programming languages like in C data are categorized in different groups.
Function
Functions are the building blocks of a programming language. A function performs a designated task.
In C language
Syntax to write function without input
main(), add(), nothing()
Syntax to write function with integer input(add, subtract, multiply, divide)+ no output
void main(int x, int y)
Syntax to write function with integer input + integer output
int main(int x, int y)
Syntax to write function with integer input + character output
char main(int x, int y)
Types of Function
1. User defined function- defined by the programmer or user to perform designated tasks.
2. Pre defined functions(Library function)- function predefined to perform certain tasks. These functions are used by including their definition in user defined functions. The square root function→ sqrt(x) function is used with input x and this function is defined in the math.h library.
Similarly, printf() and scanf() → most used pre defined function(defined in stdio.h)
Example of Function
Void main()
{
}
Here
main() { --> start of Program
} --> end of program
Next program is Printing Hello Program
#include <stdio.h>
Void main()
{
printf("Hello");
}
In this program printf() is a function with input Hello text. And the print function is defined in stdio.h (#include <stdio.h> → to include the definition print function)
Printing Integer value Program
#include <stdio.h>
Void main()
{
Int a= 3; // defining an integer with alphabet a= 3
printf("Number = %d", a);
/* in print function whater written between “ ” will get displayed on output
The print function replace value after % (%d will get printed as value of a that is 3)
*/
}
Comments in C language
// → program will not execute things written after this(single line comment)
/*...........*/ → multi line comment
Except comments every line ends with a semicolon(;)
Comments
Post a Comment