Thursday, 15 August 2019

Writing first C program | How to write C program

C program is a collection of different functions. A function is a self contained block that performs a single task. For example consider the following program




/* this program prints a value */
int show(int a);
void main()
{
 int a;
 printf(" enter a value");
 scanf("%d",&a);
 show(a);

}

int show()
{
 printf(" value of a is=%d",a);
}
In the above program the first line is a comment line, and it follows a global declaration section, then it follows main() method.

In main() method we are declaring a variable to hold values. The after we are reading the value using standard input and output functions scanf() and printf(). Then we are calling the user defined function with some parameters. The sun program section contains implementation for user defined function. It calculates 'a' value and print it on the screen.

0 comments :

Post a Comment

Note: only a member of this blog may post a comment.

Machine Learning

More

Advertisement

Java Tutorial

More

UGC NET CS TUTORIAL

MFCS
COA
PL-CG
DBMS
OPERATING SYSTEM
SOFTWARE ENG
DSA
TOC-CD
ARTIFICIAL INT

C Programming

More

Python Tutorial

More

Data Structures

More

computer Organization

More
Top