Docsity

C programming experiment, Schemes and Mind Maps of C programming

Toggle sidebar
bg1
PROGRAM-1
AIM: To learn about the C Library, Preprocessor directive, Input- output statement.
SOFTWARE REQUIRED: Turbo C/C++
THEORY:
โ—C Libraries:
A library in C consists of pre- defined functions, constant keywords and header
files like <stdio.h>, <conio.h>, <string.h>, <stdlib.h>, etc. A library in C is a
group of functions and declarations, exposed for use by other programs.
a) <stdio.h>: Defines core input and output functions like printf( ),
scanf( ).
b) <conio.h>: Contains functions for Console input/output functions like
clrscr( ), getch( )
c) <string.h>: Defines string handling functions like strrev( ), strlen( ),
strcpy(), strcmp( ), strcat( ).
โ—Preprocessor Directives:
Preprocessor programs provide preprocessors directives which tell the compiler
to preprocess the source code before compiling. All of these preprocessor
directives begin with a โ€ž#โ€Ÿ (hash) symbol. This (โ€ž#โ€Ÿ) symbol at the beginning of a
statement in a C/C++ program indicates that it is a pre-processor directive. We
can place these preprocessor directives anywhere in our program. Examples of
some preprocessor directives are: #include, #define, #ifndef etc.
โ—Input- Output Statements:
Input means to provide the program with some data to be used in the program
and Output means to display data on screen or write the data to a printer or a file.
C programming language provides many built-in functions to read any given
input and to display data on screen when there is a need to output the result.
There are two types of input- output functions:
1. Formatted Input- Output Functions: printf( ), scanf( ).
2. Non- Formatted Input- Output Functions: getche( ), getch( ), putch( ),
putche( ), etc.
pf3
pf4

Partial preview of the text

Download C programming experiment and more Schemes and Mind Maps C programming in PDF only on Docsity!

PROGRAM-

AIM: To learn about the C Library, Preprocessor directive, Input- output statement. SOFTWARE REQUIRED: Turbo C/C++ THEORY: โ— C Libraries: A library in C consists of pre- defined functions, constant keywords and header files like <stdio.h>, <conio.h>, <string.h>, <stdlib.h>, etc. A library in C is a group of functions and declarations, exposed for use by other programs. a) <stdio.h>: Defines core input and output functions like printf( ), scanf( ). b) <conio.h>: Contains functions for Console input/output functions like clrscr( ), getch( ) c) <string.h>: Defines string handling functions like strrev( ), strlen( ), strcpy(), strcmp( ), strcat( ). โ— Preprocessor Directives: Preprocessor programs provide preprocessors directives which tell the compiler to preprocess the source code before compiling. All of these preprocessor directives begin with a โ€ž#โ€Ÿ (hash) symbol. This (โ€ž#โ€Ÿ) symbol at the beginning of a statement in a C/C++ program indicates that it is a pre-processor directive. We can place these preprocessor directives anywhere in our program. Examples of some preprocessor directives are: #include , #define , #ifndef etc. โ— Input- Output Statements: Input means to provide the program with some data to be used in the program and Output means to display data on screen or write the data to a printer or a file. C programming language provides many built-in functions to read any given input and to display data on screen when there is a need to output the result. There are two types of input- output functions:

  1. Formatted Input- Output Functions : printf( ), scanf( ).
  2. Non- Formatted Input- Output Functions: getche( ), getch( ), putch( ), putche( ), etc.

CODE:

#include<stdio.h> #include<conio.h> void main( ) { int a, b; printf( โ€œEnter two numbers:); scanf(โ€œ%d %dโ€,&a,&b); int c; c=a+b; printf(โ€œAdded result = %dโ€,c); getch( ); } OUTPUT OF THE CODE: