Introduction of a C Program Md. Alamgir Hossain Lecturer Dept. of CSE, Prime University Mail: alamgir.cse14.just@gmail.com
Our first C program
Which part is used for why?? #include <stdio.h> includes the standard input output library functions. The printf() function is defined in stdio.h . int main(); The main() function is the entry point of every program in c language. printf(); The printf() function is used to print data on the console. return 0; The return 0 statement, returns execution status to the OS. The 0 value is used for successful execution and 1 for unsuccessful execution.
Variable in C A variable is a name of the memory location. It is used to store data. Its value can be changed, and it can be reused many times. It is a way to represent memory location through symbol so that it can be easily identified. Let's see the syntax to declare a variable: type variable_list; The example of declaring the variable is given below: int a; float b; char c; Here, a, b, c are variables. The int, float, char are the data types.
Variable in C We can also provide values while declaring the variables as given below: int a =10, b = 20; //declaring 2 variable of integer type float f = 20.8; char c = 'A'; Rules for defining variables A variable can have alphabets, digits, and underscore. A variable name can start with the alphabet, and underscore only. It can't start with a digit. Not allow: int 9a; No whitespace is allowed within the variable name. Not Allow: int ab cd; A variable name must not be any reserved word or keyword, e.g. int, float, etc. Valid variable names: int a; int _ab; int a30; Invalid variable names: int 2; int a b; int long;
Basic Data Types Size and Range in C Basic Data Type: int, char, float, double Data Types Memory Size Range char 1 byte -128 to 127{-(2 n-1 -1) to (2 n-1 )} int 2 byte −32,768 to 32,767 float 4 byte double 8 byte
Format Specifier in C The Format specifier is a string used in the formatted input and output functions. The format string determines the format of the input and output. The format string always starts with a '%' character. The commonly used format specifiers in printf() and Scanf() function are: Format specifier Description %d It is used to print the integer value. %f It is used for printing the decimal floating-point values. By default, it prints the 6 values after '.'. %c It is used to print the unsigned character. %lf Double Value
Printing Integer value in C
Printing Character value in C
Printing Float and Double value in C
Thank You

2. introduction of a c program

  • 1.
    Introduction of aC Program Md. Alamgir Hossain Lecturer Dept. of CSE, Prime University Mail: alamgir.cse14.just@gmail.com
  • 2.
    Our first Cprogram
  • 3.
    Which part isused for why?? #include <stdio.h> includes the standard input output library functions. The printf() function is defined in stdio.h . int main(); The main() function is the entry point of every program in c language. printf(); The printf() function is used to print data on the console. return 0; The return 0 statement, returns execution status to the OS. The 0 value is used for successful execution and 1 for unsuccessful execution.
  • 4.
    Variable in C Avariable is a name of the memory location. It is used to store data. Its value can be changed, and it can be reused many times. It is a way to represent memory location through symbol so that it can be easily identified. Let's see the syntax to declare a variable: type variable_list; The example of declaring the variable is given below: int a; float b; char c; Here, a, b, c are variables. The int, float, char are the data types.
  • 5.
    Variable in C Wecan also provide values while declaring the variables as given below: int a =10, b = 20; //declaring 2 variable of integer type float f = 20.8; char c = 'A'; Rules for defining variables A variable can have alphabets, digits, and underscore. A variable name can start with the alphabet, and underscore only. It can't start with a digit. Not allow: int 9a; No whitespace is allowed within the variable name. Not Allow: int ab cd; A variable name must not be any reserved word or keyword, e.g. int, float, etc. Valid variable names: int a; int _ab; int a30; Invalid variable names: int 2; int a b; int long;
  • 6.
    Basic Data TypesSize and Range in C Basic Data Type: int, char, float, double Data Types Memory Size Range char 1 byte -128 to 127{-(2 n-1 -1) to (2 n-1 )} int 2 byte −32,768 to 32,767 float 4 byte double 8 byte
  • 7.
    Format Specifier inC The Format specifier is a string used in the formatted input and output functions. The format string determines the format of the input and output. The format string always starts with a '%' character. The commonly used format specifiers in printf() and Scanf() function are: Format specifier Description %d It is used to print the integer value. %f It is used for printing the decimal floating-point values. By default, it prints the 6 values after '.'. %c It is used to print the unsigned character. %lf Double Value
  • 8.
  • 9.
  • 10.
    Printing Float andDouble value in C
  • 11.