1. C Learning

C Programming Language First Program

Rules to Write a C program

  • − All lines of C statements must end with a semicolon.
  • − C is case-sensitive. That is, uppercase and lowercase characters are different. Usually, the statements are typed in lowercase.
  • − A C Program statement can be split into many lines or can be written in one line.
  • − Braces must always match upon pairs, i.e., every opening brace { must have a matching closing brace }.
  • − All C program starts with void main( ) function. 6. Comments cannot be nested. For example,
  • − /* Welcome to C World ,/* programming*/ */
  • − Comment can be split into more than one line as per the user preference.

Execution of C Program

To write and run a C program, given steps should be followed.

Creation of Source Program

−Create a C program file in various C compilers are available under MS-DOS, Turbo C Editor etc.

Compilation of a C Program

− Turbo C compiler is user friendly yet free and provides an integrated program development environment.

So, selecting a key combination can do the compilation. That means press Alt + F9 for compilation.on.

Program Execution

− In Turbo C environment, the RUN option will do the compilation and execution of a program. Press Ctrl + F9 for execution the program.

printf( ) Function: Writing Data for Output

The printf( ) function is used to write information to console (normally computer screen).

The main structure of this function is printf(format string, list of arguments);The format string contains the following:

  • − Characters that can be simply printed on the screen.
  • − Specifications that begin with a % sign and define the output format for display of each item.
  • − Escape series characters that start with a sign such as n, t, b etc.
Character Argument Resulting Output
c character A Single Character
d integer Signed decimal integer
s String Print Character Strings
f floating Point Single floating point Number

scanf( ) Function: getting user input

scanf() function used to accept value from the standard input device. This means that the program gets input values for variables from users.

The scanf( ) function is a built-in C function that allows a program to accept user input from the keyboard.

The structure of this function is scanf(format string &list of arguments);

− scanf %d , &a ;

− scanf %d %c %f ,&a, &b, &c ;

This article is written by our awesome writer
Comments to: C Programming Language First Program

Your email address will not be published. Required fields are marked *

Attach images - Only PNG, JPG, JPEG and GIF are supported.

New Dark Mode Is Here

Sign In to access the new Dark Mode reading option.

Explore Tutorials By Categories

Login

Welcome to Codeverb

Ready to learn something new?
Join Codeverb!

Read Smart, Save Time
  •  
    Strength indicator
  •  
  •  
    Log In | Lost Password