Saturday, 20 June 2015

Introduction to C Programming Syntax

Output Statement

Printf(format string, var1, var2..)

printf("Hello World");

  • It displays the string. It is supposed to be printed as it is as long as we introduce some valuable string.
 printf("Given Value is %d", a);

  • %d is a specifier which takes value of a. The number of specifiers are mentioned, so are the number of variables given to printf.
Printf returns number of characters printed

Input Statement

scanf(format string, &var1, &var2)

Everything else is same but we give & when we enter any variable. & is the pointer which is used to store the address location for variable.

Other format specifiers
%d: Integer
%f: Float
%c: Character
%e: exponential

Scanf returns 1 for correct input and 0 for wrong input

Statements
  • Simple Statements
  • Compound Statements
    • Conditional
      • If else
      • Switch
    • Loops
      • For
      • While
      • Do while


No comments:

Post a Comment