Thursday, December 28, 2017

BASIC PROGRAMMING CONCEPTS

Basic Program in C to Add two number with very simple and define way for beginners.

#include<stdio.h>
#include<conio.h>


void main()
{
  int a, b, c;
 printf("\n Enter the value of a and b");
 scanf("%d%d",&a,&b);
 c=a+b;
 printf("result is = %d" ,c);
 getch();
 clrscr();

}


Define as very simple:

# include is used as preprocessing directive "#include"


<Stdio.h> used as c standard library covering all the built in functions.


<conio.h> used for console input/ouptput.


void main()  when use void main  function does not to return value 

int data type


printf()  and scanf()
  fuctions both are defined in <stdio.h> header file


prinf() used with %d used to diplay integer , %c to display charater , %f to display float etc.

printf() used to print values on to the output screen


scanf() fuction is use to read character from keyboard


clrscr() it is predefined in conio.h(console input oputput header file) used to clear the console screen.


getch(); it is used to hold the program execution.which wait until user enter a value or character.


getch() and getche() are used to read a caracter from screen.


(+) use as operator like ( +, -, *, / etc. )


compiler view:

Add two numbers in C





No comments:

Post a Comment

BASIC PROGRAMMING CONCEPTS

Basic Program in C to Add two number with very simple and define way for beginners. #include<stdio.h> #include<conio.h> vo...