definitions

basic symbols and definition of the C program:

                                       now, this time we will see some important basics symbols and basic definitions of the C program. suppose if you want to become an intermediate programmer some definitions and some syntax are important.no we will see what are the important definition. 
                                





   
  
 
scanf(); 
              which means It is used to read information from the standard input device (keyboard). This the function used to enter any combination of input. scanf() function starts with the string argument and may contain an additional argument.

the syntax for scanf(); :-
scanf(“control_strings”,&var1,&var2,...&varn); 


Description the control string consist of character groups. each character group must begin with % sign.
Example int a; 
scnaf(“%d”,&a); 

Control String:
 
It is the type of data that the user going to accept via input statements, this can be formatted and always preceded with a % symbol. The below table shows various control strings for different data types.



formating code :






Rules for writing scanf() functions: 


a) The control string must start with (%) sign and must be within the quotation. 
b) If there is more number of input data items, items must be separated by commas and must be preceded with (&) sign except for string input. 
c) The control string and input giving must match with each other. 
d) It must have termination with a semicolon. 
e) The scanf() reads the data value until the blank space in numeric input or a maximum number of characters has been read, or an error is detected.





 printf(); :-

Output data or the result of an operation can be displayed from the computer to standard output device using printf(). excepts This function used to output any combination of data. It is similar to scanf() that it displays data rather than input. 

 the syntax for printf() is;
   
            printf(“control_strings”, var1,var2,...varn); 


Description of the control string consists of character groups. each character group must begin with a % sign.
Example
printf(“result is : %d”, a); 
printf(“%f”, b);
printf(“%s”,c);

Rules for writing printf() functions: 
a) Place appropriate heading in the output. 
b) If there is more number of data items, items must be separated by commas and must not be preceded with (&) sign. 
c) The control string and input giving must match with each other. 
d) It must have termination with a semicolon. 
e) The control string must start with (%) sign and must be within the quotation. 
f) Provide blank space in between numbers for better readability.

Program  for the sum of two numbers:

 

#include<stdio.h> \\header file

#include<conio.h>                        

void main ()  \*void main its contains empty values

{

 int a,b,sum;

 printf ("enter the value:\n");

 scanf ("%d”, &a);      \*scanf ();*\

 scanf ("%d”, &b);

 sum=a+ b;    \*adding two numbers*\

printf("sum is: %d", sum);

getch();

 

 

}

   output: -

    enter the value:
     2
     2
     sum is :4   





getch(); :-
The getch() function reads a single character directly from the keyboard, without echoing to the screen. 

The syntax:

getch();
we shouldn't give any statement in between the parentheses.

getche(); :-
The getche() function reads a single character directly from the keyboard, and echoes it to the current text window. getche(); and getch(); both are same

 gets(); :-
 It is used to read the string (a group of characters) from the standard input device called a keyboard.

the Syntax
gets(char type of array variable ); 

Description any valid c variable declared as one-dimensional char type.
Example
gets(s);

puts(); :-
It is used to display/write the string to a standard output device called a monitor.

Syntax
puts(char type of array variable ); 
Description any valid c variable declared as one-dimensional char type
Example
puts(s); 
Program: for gets & puts demo:

 

  #include<stdio.h> \\ header file

 int main()      \\ main file its  contains integer data type

{

   char name[20];

  puts("enter your name:"); \* puts(); *\

  gets(name);            \*gets();*\

  puts("your name is:");

  puts(name);

 

 }

   output: -

enter your name: coding master

 your name is: coding master  


comments:-
comments normally this use for highlighting your program. suppose if you want to say what you have written on your code some peoples can easily understand why you using some function or some statement on your program. but some people can't understand, that time you have to use comments symbols everyone can easily understand. But one thing, when you use comments in any line our pc doesn't exist our comments, it only exists our program. see above all the programs we have used some comments.

\\ comments go here
\*comments go here*\

these are the basic definitions and syntax.




           
      

1 comment:

  1. Thank u for ur lovable wrk it was easy to understand for the beginners

    ReplyDelete