Wednesday, 21 May 2014

C PROGRAM

Hi if you want any c program  comment here i will post your wanted program thank you.........

Sunday, 11 May 2014

For loop in c

For loop in c 
#include<stdio.h>             //header file stdio.h
#include<conio.h>            //header file conio.h
main()
{
int i,n;                                       //variable declaration
printf("enter the number of times for loop runs");
scanf("%d",&n);
for(i=0;i<n;i++)                       //for loop  
{
printf("the for loop run %d time",i);
}
getch();
}                                          //end of the program

Address operator(&) in c

 Address operator(&) in c
#include<stdio.h>                           //header file stdio.h
#include<conio.h>                       //header file conio.h
main()
{                                                        //start of the program
int a,b;                                     //variable declaration
clrscr();
printf("the address of a is %u",&a);  //print address of a                                                    variable  using  address operator (&) 

printf("the address of b is %u",&b); //print address of b                                                 variable  using    address operator (&)
getch();
}                                                              //end of the program

Pointer in c

Pointer in c

#include<stdio.h>                       //header file stdio.h
#include<conio.h>                 //header file conio.h
main()
{
int *p,a=10;        //pointer variable and normal variable declaration
clrscr();
p=&a;                           //assign address of a to p
printf("the address of a is %u",p);
printf("the value of a is %d",*p);
getch();
}                          //end of the program

Getchar() function used in c

Getchar() function used in c

#include<stdio.h>                   //header file stdio.h
#include<conio.h>                   //header file conio.h
main()
{                                             //start of the program
char s;                               //variable declaration
s=getchar();                      //getchar function used
printf("you entered is %d",s);
getch();
}                                            //end of the program


Guess a magic number game in c

Guess a magic number game in c

#include<stdio.h>             //header file stdio.h
#include<conio.h>             //header file conio.h
#include<stdlib.h>              //header file stdlib.h
main()
{
int guess,magic;                     //variable declaration
magic=rand();                 //using random generator function
printf("enter you guess number");
scanf("%d",&guess);            //assign value to guess
if(guess==magic)                  //checking conditions
printf("right you won");
else{
printf("wrong you lose");
printf("the right answer is %d",magic);
}
getch();
}                                          //end of the program

Saturday, 10 May 2014

QOUTIENT AND REMAINDER PROGRAM IN C

QOUTIENT AND REMAINDER PROGRAM IN C

#include<stdio.h>           //header file stdio.h
#include<conio.h>            //header file conio.h
main()                                      //main() function
{                                            //start of the program
int n1,n2,qoutient,remainder;         //variable declaration
clrscr();
printf("enter the two numbers");
scanf("%d%d",&n1,&n2);          //reading values from user
qoutient=n1/n2;
remainder=n1%n2;
printf("qoutient is %d remainder is %d",qoutient,remainder);
getch();
}                                  //end of the program

FIND THE BIGGEST VALUE OF 2 NUMBERS

FIND THE BIGGEST VALUE OF 2 NUMBERS

#include<stdio.h>         //header file stdio.h
#include<conio.h>          //header file conio.h
main()                                    //main() function
{                                          //start of the program
int a=10,b=15,big;                   //variable declaration
big=(a>b)?a:b;                     //conditional operator
printf("biggest number =%d",big);
getch();
}                                         //end of the program

Friday, 9 May 2014

HOW TO CALCULATE AREA OF THE TRIANGLE IN C PROGRAM

HOW TO CALCULATE AREA OF THE TRIANGLE IN C PROGRAM

#include<stdio.h>                 //header file stdio.h
#include<conio.h>                  //header file conio.h
main()                                            //main function
{                                                     //start of the program
int b,h ,area;                                //variable declaration
clrscr();
printf("enter the base and height of the triangle");
scanf("%d%d",&b,&h);                //reading values from user
area=b*h/2;                               //area of the triangle formula
printf("area of the triangle is %d",area);
getch();
}                                                     //end of the program

FIND SQUARE OF THE GIVEN NUMBER IN C

FIND SQUARE OF THE GIVEN NUMBER IN C

#include<stdio.h>      //header file stdio.h
#include<conio.h>     //header flie conio.h
main()                                  //main function
{                                         //start of the program
int a;                                   //variable declaration
printf("enter the number ");
scanf("%d",&a);                  //reading value from user
a=a*a;                                     // formula for square
printf("square of the given number is %d",a);
getch();
}                                       //end of the program

FINDING EVEN OR ODD NUMBER IN C PROGRAM

FINDING EVEN OR ODD NUMBER IN C PROGRAM

#include<stdio.h>     //header file string.h
#include<conio.h>    //header file conio.h
main()                                    //main function
{                                         //start of the program
int a;                                  //variable declaration
clrscr();
printf("enter the number");
scanf("%d",&a);                 //read number from user
if(a%2==0)                     //if statement works only on condition true
{                                       //if statement block runs
printf("you entered number is even");
}                                       //end of if statement block
else                             //when if condition fails else block runs
{                                            //start of else block
printf("you entered number is odd");
}                                             //end of else block
getch();
}                                              //end of the program

STRCPY() FUNCTION IN C

STRCPY() FUNCTION IN C

#include<stdio.h>              //header file stdio.h
#include<conio.h>            //header file conio.h
#include<string.h>             //header file string.h
main()                                          //main() function
{                                                //start of the program
char a[10],b[10];                     //string variable declaration
clrscr();
printf("enter the string ");
scanf("%s",a);                     //read the string from the user
strcpy(b,a);            //strcpy() is use to copy string from a variable                                                                        to b varaible
printf("the copied string is %s",b);
getch();
}                                                  // end of the program

SIZEOF OPERATOR IN C

SIZEOF OPERATOR IN C

#include<stdio.h>                     //header file stdio.h
#include<conio.h>                     //header file conio.h
main()                                                      //main function
{                                                           // start of the program
int a;                                                       //variable declaration
clrscr();   //this function is used to clear the previous output screen
printf("the size of a is %d",sizeof(a)); //prints the size of a                 getch();
}                                                     // end of the statement

C PROGRAM TO CALCULATE SIMPLE INTEREST

C PROGRAM TO CALCULATE SIMPLE INTEREST

#include<stdio.h>                               //header file stdio.h
#include<conio.h>                              //header file conio.h
main()                                                          //main function
{                                                                 //start of the program
int p,n,r,simple_interest;                            //variable declaration
printf("enter the values of p,n,r");
scanf("%d%d%d",&p,&n,&r);              // read the values from user
simple_interest=p*n*r/100;                     //simple interest formula
printf("simple interest is %d",simple_interest); 
getch();
}                                                           //end of the program

IF ELSE STATEMENT IN C PROGRAM

IF ELSE STATEMENT IN C PROGRAM

#include<stdio.h>       //header file stdio.h
#include<conio.h>       //header file conio.h
main()                                     //main function
{                                          //start of the program
int a,b;                               //variable declaration
clrscr();  //clrscr function is used to clear the previous output screen
printf("enter the values of a and b ");
scanf("%d%d",&a,&b);
if(a==b)       //if block works only on condittion is true
{
printf("the values of a and b is equal");
}
else       // if condition fails else block run
{
printf("the values of a and b is not equal");
}
getch();
}//end of the program

SIMPLE IF STATEMENT IN C PROGRAM

SIMPLE IF STATEMENT IN C PROGRAM

#inlcude<stdio.h>   //header file stdio.h
#include<conio.h> //header file conio.h
main()                              //main function
{                                       //start of the program
int a,b;                                //variable declaration
clrscr();        //clrscr function use to clear the previous output screen
printf("enter the values of a and b");
scanf("%d%d",&a,&b);      //reading values from user
if(a==b)                //if statement works only condition is true 
{
printf("the values of a and b is equal");
}
getch();
}                           //end of the program

C SIMPLE PROGRAM USING WHILE LOOP

C SIMPLE PROGRAM USING WHILE LOOP

#include<stdio.h>              //header file stdio.h
#include<conio.h>            //header file conio.h
main()                                // main function
{                                          //start of the program
int a=0;                                //variable declaration
clrscr();      //clrscr function use to clears the previous output screen
while(a< 9)//while loop runs until condition is satisfied
{                       //start of the while loop block
printf("while loop runs");
a++;                      //increment the variable a
}                           //end of the while loop block
printf("while loop stop");
getch();
}             //end of the program

Your feed back and comments are welcomed and appreciated!!

HOW TO PRINTING THE MESSAGE IN C PROGRAM

HOW TO PRINTING THE MESSAGE IN C PROGRAM

#include            //header file stdio.h
#include           //header file conio.h
main()                                //main function
{                                          //start of the progarm
clrscr();                                //clrscr function use to clears the screen
//to print the message
printf("Welcome To LETS SEE C PROGRAM BLOG ");
getch();
}                                            //end of the program

SIMPLE C PROGRAM FOR PRINTING STRINGS

SIMPLE C PROGRAM FOR STRINGS

#include      //header files stdio.h
#inlcude    //header files conio.h
main()                         //main() function
{                              //start of the program
char str[10];             //declare string variable
printf("enter the string");
scanf("%s",str);          //read strings from user
printf("the entered strings are \n %s",str); //output displayed
getch(); 
}                                    //end of the program

C Simple program using float data type

C PROGRAM USING FLOAT DATATYPE

#include
#include
main(){
float a;
a=10.2;
printf("the value of a is %f",a);
getch();
}

Thursday, 8 May 2014

C Simple Addition Program

C ADDITION SIMPLE PROGRAM

1.#include
2.#include
3.main(){
4.int a,b,add;
5.clrscr();
6.printf("Enter the numbers for addition");
7.scanf("%d%d",&a&b);
8.add=a+b;
9.printf("the addition of two numbers %d",add);
10.getch();
11.}

PROGRAM EXPLANATION

Line 1 : Header file stdio.h standard input output 

Line 2 : Header file conio.h

Line 3 : main() function is use for compiler in where the program is to start {-denotes the start of the program

Line 4 : datatype integer represents int  a,b,add are the variables in this program

Line 5 : clrscr () function used for print the output in new screen

Line 6 : prints the statement Enter the number for additon

Line 7 : read numbers and stored in variables a,b

Line 8 : the expression a+b is stored in add variable

Line 9 : print the statement the addition of two numbers 

Line 10 : getch() function is used for hold the output screen

Line 11 : } represents the end of the program