Sunday, July 14, 2013

write a program to print following number pattern ?

1 2 3 4
  2 3 4
     3 4
        4
Program:
#include<stdio.h>
#include<conio.h>

void main()
{
   int r, p, k,g=0,h=1;
   clrscr();
   printf("\n enter the no of row");
   scanf("%d", &r);
   for ( k = r ; k >= 1 ; k-- )
   {
       for ( p = 1 ; p <= g; p++ )
       printf(" ");
       g++;
       for ( p = h;p <=r ; p++)
       printf("%d", p);
       h++;

       printf("\n");
   }

   getch();
}
 
Output:
image
{ Read More }


Saturday, July 13, 2013

write a program to print following number pattern ?

4 3 2 1
  3 2 1
    2 1
      1
Program:
#include<stdio.h>
#include<conio.h>

void main()
{
   int r, p, k,g=0;
   clrscr();
   printf("\n enter the no of row");
   scanf("%d", &r);
   for ( k = r ; k >= 1 ; k-- )
   {
       for ( p = 1 ; p <= g; p++ )
       printf(" ");
       g++;
       for ( p = r;p >0 ; p --)
       printf("%d", p);
       r--;

       printf("\n");
   }
   getch();
}

Output:
image
{ Read More }


write a program to print following number pattern ?

     1
    12
  123
 1234
12345
Program:
#include<stdio.h>
#include<conio.h>

void main()
{
   int r, p, k,g=0,h=1;
   clrscr();
   printf("\n enter the no of row");
   scanf("%d", &r);
   for ( k = r ; k >= 1 ; k-- )
   {
       for ( p = --r; p >0; p--)
       printf(" ");

       for ( p = 1;p <=h ; p++)
       printf("%d", p);
       h++;

       printf("\n");
   }
   getch();
}

Output:
image

{ Read More }


write a program to print following number pattern ?

1
23
456
78910
Program:
#include<stdio.h>
#include<conio.h>

void main()
{
   int r, p, k,h=1;
   clrscr();
   printf("\n enter the no of row");
   scanf("%d", &r);
   for ( k = 1 ; k <= 5 ; k++ )
   {
       for ( p =1; p <=k; p++,h++)
       printf("%d", h);

       printf("\n");
   }

   getch();
}

Output:
image


{ Read More }


Thursday, July 11, 2013

write a program to print the following ‘*’ pattern ?

    *******
     *****
      ***
       *

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

void main()
{
  int n,r,a,p;
  clrscr();
  printf(" enter the no of rows  ");
  scanf("%d",&n);
  for(r=1;r<=n; r++)
  {
   for(p=r; p>=1; p--)
    printf(" ");
   for(a=1; a<=n-r;a++)
    printf("*");
   for(a=n-r-1; a>=1; a--)
    printf("*");
   printf("\n");
  }
  getch();
}

Output:
image

{ Read More }


Write a Program to print the following * pattern?

      *
    ***
  ***** 
*******                              
Program:
#include<stdio.h>
#include<conio.h>

void main()
{
  int n,r,a,p;
  clrscr();
  printf("enter the no of rows ");
  scanf("%d",&n);
  for(r=1;r<=n; r++)
  {
   for(p=n-r; p>=1; p--)
       printf(" ");
   for(a=r; a>=1; a--)
        printf("*");
   for(a=r; a>1; a--)
        printf("*");
   printf("\n");
  }
  getch();
}
Output:
image
{ Read More }


Tuesday, July 2, 2013

Write a program to find square root of the given ni without using sqrt function ?

Program:
#include<stdio.h>
#include<conio.h>
#include<math.h>

void main()
{
const float x=0.00001;
float g=1.0,no;
clrscr();
printf("\n enter the number");
scanf("%f",&no);
do
{
g=(no/g+g)/2.0;
}
while(abs(g*g-no)>=.00001);
printf("\n the square root of %.0f is %.4f",no,g);
getch();
}



Output:

 


{ Read More }


Sunday, June 30, 2013

Write a program to find no of letter, space,symbol in given line?

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

void main()
{
char c,number=0,ucharacter=0,lcharacter=0,space=0,symbol=0;
clrscr();
printf("\n enter the character \n\n");
do{
c=getchar();
if(c>='a'&&c<='z')
lcharacter++;
else
if
(c>='A'&&c<='Z')
ucharacter++;
else
if
(c==' ')
space++;
else
if
(c>='0'&&c<='9')
number++;
elsesymbol++;
}
while(c!='\n');
printf("\nupper letter=%d\nlower letter=%d\nnumber=%d\nspace=%d\nsymbol=%d",ucharacter,lcharacter,number,space,(symbol-1));

getch();
}

Output:
image


{ Read More }


Saturday, June 29, 2013

Write a program to whether the given character is vowel or not?

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

void main()
{
char c;
clrscr();
printf("\n enter the character ");
scanf("%c",&c);
switch(c)
{
case'a':
case'e':
case'i':
case'o':
case'u':
printf("\n the %c  is vowel",c);
break;
default:

printf("\n the %d  is consonant",c);
}

getch();
}

output:
image


{ Read More }


Write a program to find the smallest no in given array ?

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

void main()
{
int no[100],i,n,high=
32767;//maximum possible value in signed integer
clrscr();
printf("\n enter the no of no ");
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&no[i]);
if(high>no[i])
high=no[i];
}

printf("\n the %d  is smaller",high);
getch();
}

Output:
image


{ Read More }


Write a program to find the greatest no in given array?

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

void main()
{
int no[100],i,n,high=0;
clrscr();
printf("\n enter the no of no ");
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&no[i]);
if(high<no[i])
high=no[i];
}

printf("\n the %d  is greater",high);
getch();
}

Output:
image



{ Read More }


Write a program to find the greatest of 3 no?

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

void main()
{
int no1,no2,no3;
clrscr();
printf("\n enter the  no1,no2 and no3 ");
scanf("%d%d%d",&no1,&no2,&no3);

if(no1>no2&&no1>no3)
printf("\n the %d  is greater",no1);
else
if
(no2>no3)
printf("\n the %d is greater",no2);
elseprintf("\n the %d is greater",no3);
getch();
}

Output:
image


{ Read More }


Write a program to find the greatest of 2 no?

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

void main()
{
int no1,no2;
clrscr();
printf("\n enter the  no1 and no2 ");
scanf("%d%d",&no1,&no2);

if(no1>no2)
printf("\n the %d  is greater",no1);
elseprintf("\n the %d is greater",no2);
getch();
}

Output:
image


{ Read More }


Write a program to find the given no is Armstrong or not ?

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

void main()
{
int no1,temp1,sum=0,n;
clrscr();
printf("\n enter the  no ");
scanf("%d",&no1);
temp1=no1;
while(no1!=0)
{
n=no1%10;
sum=sum+n*n*n;
n01=no1/10;
}
if(sum==temp1)
printf("\n the %d  is armstrong",temp1);
elseprintf("\n the %d not armstrong",temp1);
getch();
}

Output:
image
What is Armstrong no ?
the no is said to be armstrong if satisfy the following condition ,i.e 153=1*1*1+5*5*5+3*3*3 

{ Read More }


Write a program to find the given two no is co-prime or not ?

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

void main()
{
int no1,no2,temp,temp1,temp2;
clrscr();
printf("\n enter the two no decesending order ");
scanf("%d%d",&no1,&no2);
temp1=no1;
temp2=no2;
while(no2!=0)
{
temp=no1%no2;
no1=no2;
no2=temp;
}
if(no1==1)
printf("\n the %d and %d is co-prime",temp1,temp2);
else
printf("\n the %d and %d is not co-prime",temp1,temp2);
getch();
}

Output:
image
What is co-prime ?
The 2 no which has highest common factor as 1 is called co-prime.



{ Read More }


Write a program to find the given no is prime or not ?

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

void main()
{
int n,i,x=0;
clrscr();
printf("\nEnter the no");
scanf("%d",&n);
for(i=2;i<=n/2;i++)
{
if(n%i==0)
x++;
}
if(x>1)
printf("\n the %d is prime",n);
else

printf("\n the %d is not prime",n);
getch();
}

Output
image
What is prime no?
the number which is not divisible by any other no except that no  is called prime no
{ Read More }


Write a program to print the Fibonacci series ?

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

void main()
{
int n1=0,n2=1,n,sum=0;
clrscr();
printf("\nEnter the limit of the series");
scanf("%d",&n);
printf("\n%d",n1);
printf("\n%d",n2);
while(sum<n)
{
sum=n1+n2;
n1=n2;
n2=sum;
printf("\n%d",sum);
}
getch();
}

Output:
image
What is Fibonacci series ?
the series which is obtained by addition of two previous no is called Fibonacci series.
{ Read More }


Write a program to display text and their background in color?

Problem:
we have to write a program that will display the text in color and also their background in color

Solution:
the conio.h  header file has the in build function to print the text in color ,below table show available color and their value, whether it can be used for background and foreground .
image
Program coding:

#include <conio.h>
void main()
{
int i,j;
clrscr();
for (i=0,j=9; i<9; i++,j--)
{
cprintf("\r\nC4engineer.blogspot.com\r\n");
textcolor(i+1);
textbackground(j+1);
}
getch();

}
  
Output:
image


{ Read More }


Moving text without using graphics fuction

Problem:
Program to moving the text horizontally , for this purpose we need to know the width of the output screen, so that we make an circular rotation.to see the movement of text without specifying width of the screen.
Solution:
//width of the output screen
#include<stdio.h>
#include <conio.h>
#include<dos.h>

int main(void)

int x=0;
clrscr();

while (!kbhit()
{
clrscr();
gotoxy(x, 12);
printf("Hello world");
delay(100);//delay the control flow
x++;

if (x>=81)//width of the screen
  {
  x=0;//once it reach end of the screen , reset to beginning 

   }
}

printf(" /n width of the screen %d",x);
getch();
return 0;
}


Output:
click the below video to see output





{ Read More }


Friday, June 28, 2013

Program to determine width of the output screen

Problem:
To find the width of the output screen, which is used in program of moving text without using graphics function

Solution:
//width of the output screen
#include<stdio.h>
#include <conio.h>
#include<dos.h>

int main(void)
{  

int x=0;
clrscr();

while (!kbhit()
{
clrscr();
gotoxy(x, 12);
printf("Hello world");
delay(100);
x++;

}
printf(" /n width of the screen %d",x);
getch();
return 0;
}


Output:
image
See the Below video for procedure:-




{ Read More }


Thursday, June 27, 2013

Use of Clrscr and getch functions

In all our program we use the clrscr() and getch() function irrespective of what program it is ,if you don’t use it in your program you didn’t get any error, it  has some effect on the output display not on the out
clrscr :
clrscr means clear screen, i will clear the output of the previous program(s) . below fig, show the effect of clrscr on the output when it is not used
image
from the above image we can see that current program output is displayed along with previous output.
getch:
getch means get character, this command hold the output screen till the user press any key, without this command user cannot see the output after running the program(ctrl+F9), (can see by pressing alt+F5,after running the program). see the below video
{ Read More }


Wednesday, June 26, 2013

Write a program to print the day of the given date ?

Problem:
 To write a program to print the day of the given date .example if input is 27/6/2013 output is Thursday

Solution:

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

void main()
{
int dd,mm,yyyy,i,x,ly,ry,oday,mday=0,mday2,intex,month[12]={31,28,31,30,31,30,31,31,30,31,30,31};
char day[10]
[10] = {"sunday","monday","tuesday","wednesday","thursday","friday","saturday"};
clrscr();
printf("enter the date in the format of dd mm yyyy\n");
scanf("%d%d%d",&dd,&mm,&yyyy);
yyyy=yyyy-1;
yyyy=yyyy%400;
x=yyyy/100;
if(yyyy>=100)
yyyy=yyyy%100;
ly=yyyy/4;
ry=yyyy-ly;
oday=ly*2+ry+x*5;
oday=oday%7;
for(i=0;i<=mm-2;i++)
mday=mday+month[i];
if((yyyy+1)%4==0&&mm!=2)
mday=mday+1;
mday2=mday+dd+oday;
intex=mday2%7;
if(dd>31||(dd>29&&mm==2)||(dd==29&&mm==2&&(yyyy+1)%4!=0))
printf("\ndate is wrong");
else
printf(" \n %s",day[intex]);
getch();
}


Output:










if any doubt ,please post it on comment .
{ Read More }


Write a program to find whether the given no is perfect square or not ?

Problem:
To find whether the given no is perfect square or not . this so simple to find int and float float value of square root no is same if and only if that no is perfect square, example int sqrt of 2 is 1 and that of float is 1.414,

Solution:
#include<stdio.h>
#include<conio.h>
#include<math.h>

void main()
{
int s1,no;
float s2;
clrscr();
printf("\n enter the no ");
scanf("%d",&no);

s1=sqrt(no);
s2=sqrt(no);
if(s1==s2)
printf("\n the given no %d is square",no);
else
printf("\n the given no %d is not square",no);

getch():
}


Output:

{ Read More }


Tuesday, June 25, 2013

Write a program to find the given string is palindrome or not without using string.h header file?

Problem :
find  the given string is palindrome or not without using string.h header file ,  why this condition is given because without string.h header file we cannot use any function like strlen,strcmp,strcpy,strrev.

Solution:

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

void main()
{
char a[100],i,j,equal=0,k;
clrscr();
printf("\n enter the string ");
scanf("%s",a);
for(i=0;a[i]!='\0';i++);
for(j=i-1,k=0;a[k]!='\0';j--,k++)
if(a[j]==a[k])
equal++;
if(equal==i)
printf("\n the %s is palindrome",a);
else
printf("\n the %s is not palindrome",a);
getch();
}



{ Read More }


Write a program to Swap two no without using any third variable ?

Problem:
 Swap the 2 number without using any third variable .

Solution:

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

void main()
{
int a, b;
clrscr();
printf("\n enter the two no ");
scanf("%d%d",&a,&b);
printf("before swape \n A=%d   B=%d",a,b);
a=a+b;
b=a-b;
a=a-b;
printf("\nafter swape \n A=%d   B=%d",a,b);
getch();
}


Output:

{ Read More }


How to reduce the editior window size in c ?

whenever you open turbo c editor it provide the full screen mode , you only minimize it to taskbar, please follow the procedure below to reduce size of c editor window
step 1) open the turbo c, then minmize it to taskbar


 step 2) right click minimized turbo c then select property ,


you can see the window like this

  step 4) in the display option select window ,then press ok .see image below.


















step 5) you will get apply properties window, select save properties for future window with same tilte,then press









that's all now you can see the window in reduced size , see image below

 
{ Read More }


Write a Program to find high common factor (HFC) three no ?

Problem :
 Find Greatest Common divisor for given three no, ex125,25 and 15 HFC is 5

Solution:

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

void main()
{
int no1,no2,no3,temp,flag=0;
clrscr();
printf("\n enter the two no decesending order ");
scanf("%d%d%d",&no1,&no2,&no3);
start:
while(no2!=0)
{
 temp=no1%no2;
 no1=no2;
 no2=temp;
}
if(flag==0)
{
flag=1;
if(no1<no3)
{
no1=no3;
no2=no1;
}
else
{
no1
goto start;
}
printf("\n the highest comman factor is %d",no1);
getch();
}


Output:








if any doubt, post it on comment
{ Read More }


Write Program to find Highest common factor (HFC) of two no ?

Problem :
 Find Greatest Common divisor for given two no, ex 22 and 33 HFC is 11

Solution:

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

void main()
{
int no1,no2,temp;
clrscr();
printf("\n enter the two no decesending order ");
scanf("%d%d",&no1,&no2);
while(no2!=0)
{
 temp=no1%no2;
 no1=no2;
 no2=temp;
}
printf("\n the highest comman factor is %d",no1);
getch();
}

Output:










if any doubt , post it on comment
{ Read More }


Write a Program to find no of words in given line ?

Problem:
Write a program to no of words in given line , ex give line is "Welcome you All" and result should be printed as 3

Solution:

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

void main()
{
char a[100]="this is c language ",i,j,count=0,need_word=1,isalphabet;
clrscr();
printf("\n%s",a);
for(i=0;a[i]!='\0';i++);
for(j=0;j<i;j++)
{
if((a[j]>='a'&&a[j]<='z')||(a[j]>='A'&&a[j]<='B'))
isalphabet=1;
else
isalphabet=0;
if(isalphabet)
{
if(need_word)
{
count++;
need_word=0;
}
}
else
need_word=1;
}

printf("\nthe length of the string is %d",count);
getch();
}


Output:















if any doubt in above coding , please post it
{ Read More }


Monday, June 24, 2013

Write a program to find perfect square number near given number?

Probelm:
To find the perfect square no for given nu  , example give no 160  then it should print near perfect square is 169

Solution:

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

void main()
{
int i,j,n,avg1;
float avg2;
clrscr();
printf("enter the no");
scanf("%d",&n);
i=n;
j=n;
while(1)
{
i++;
j--;
avg1=sqrt(i);
avg2=sqrt(i);
if
(avg1==avg2)
{
printf("the near perfect square is %d ",i);
break;
}
avg1=sqrt(j);
avg2=sqrt(j);
if(avg1==avg2)
{
printf("the near perfect square is %d ",j);
break;
}
}
getch();
}

Output:
 
{ Read More }


Write a program to find the length of the string (without using strlen function) ?

Problem:
To find the length of the given string without using any strlen function

Solution:

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

void main()
{
char a[100],i,j;
clrscr();
printf("\nenter the string without space");
scanf("%s",a);
for(i=0;a[i]!='\0';i++);
printf("the length of the string is %d",i);
getch();
}


Output:
 


{ Read More }


Write a program to print string without any special character?

Problem:
You have to print the given string without any special character , example  string CO#M&*PUT^ER should be printed as COMPUTER

Sloution:

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

void main()
{
char a[100],i,j;
clrscr();
printf("\nenter the string without space");
scanf("%s",a);
for(i=0;a[i]!='\0';i++);
for(j=0;j<i;j++)
if((a[j]>='a'&&a[j]<='z')||(a[j]>='A'&&a[j]<='B'))
printf("%c",a[j]);
getch();
}

Output:

{ Read More }


Write a program to convert Decimal to Binary or Octal or Hexadecimal with menu option?

Problem:
To convert the given decimal no into binary or octal or hexadeciaml with menu option , if user enter the base 8 it should be converted into octal

Solution:

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

void main()
{
int a,b,intex[]={0,1,2,3,4,5,6,7,8,9,'A','B','C','D','E','F'},data[100],i=0,j,base;
clrscr();
printf("\n enter the no ..");
scanf("%d",&a);
printf("\n enter the base \nBinary--->2\nOctal--->8\nHexadecimal--->16");
scanf("%d",&base);
while(a!=0)
{
data[i]=a%base;
i++;
a=a/base;
}
for(i--;i>=0;i--)
{
j=data[i];
if(j<=9)
printf("%d",intex[j]);
else
printf("%c",intex[j]);
}
getch();
}

Output:


{ Read More }


Write a program to convert Decimal to Hexadecimal?

Problem: 
To convert the given decimal no into Hexadecimal without using in build function ,Example 26  shoule printed as 32

Solution:

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

void main()
{
int a,b,intex[]={0,1,2,3,4,5,6,7,8,9,'A','B','C','D','E','F'},data[100],i=0,j;
clrscr();
printf("\n enter the no ..");
scanf("%d",&a);
printf("\nthe %d to binary is ",a);

while(a!=0)
{
data[i]=a%16;
i++;
a=a/16;
}
for(i--;i>=0;i--)
{
j=data[i];
if(j<=9)
printf("%d",intex[j]);
else
printf("%c",intex[j]);

}
getch();


Output:

{ Read More }


Write a program to convert Decimal to Octal?

Problem:

To convert the given decimal no into octal without using in build function ,Example 26  shoule printed as 32

Solution:

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

void main()
{
int a,b,intex[]={0,1,2,3,4,5,6,7},data[100],i=0,j;
clrscr();
printf("\n enter the no ..");
scanf("%d",&a);
printf("\nthe %d to octal is ",a);

while(a!=0)
{
data[i]=a%8;
i++;
a=a/8;
}
for(i--;i>=0;i--)
{
j=data[i];
printf("%d",intex[j]);
}
getch();
}


Output:


{ Read More }


Write a program to convert Decimal to Binary?

Problem
To convert the given decimal no into binary without using in build function , exampla 11 to printed as 1011

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

void main()
{
int a,b,intex[]={0,1},data[100],i=0,j;
clrscr();
printf("\n enter the no ..");
scanf("%d",&a);
printf("\nthe %d to binary is ",a);

while(a!=0)
{
data[i]=a%2;
i++;
a=a/2;
}
for(i--;i>=0;i--)
{
j=data[i];
printf("%d",intex[j]);
}
getch();
}



Output


{ Read More }


Write a program to convert Fahrenheit to degree?

Problem: 
convert the value in Fahrenheit into degree  , and relationship between degree and Fahrenheit is D=(F-32)*1.8

solution:

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

void main()
{
float deg,frn;
clrscr();
printf("enter the Fahrenheit");
scanf("%f",&frn);
deg=(frn-32)/1.8;
printf("the %.2fF---> %.2f deg",frn,deg);
getch();
}


Output

{ Read More }


Write a program to convert degree to Fahrenheit?

Problem: 
convert the value in degree into Fahrenheit , and relationship between degree and Fahrenheit is
F= D*1.8+32

Solution:

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

void main()
{
float deg,frn;
clrscr();
printf("enter the degree");
scanf("%f",&deg);
frn=deg*1.8+32;
printf("the %.2fdeg---> %.2f F",deg,frn);
getch();
}


Output :

{ Read More }


Write a program to find 2nd or 3rd or 4th or Nth greatest no without using sorting algorithm?

Problem:
 Find asked greatest no in the given array without using sorting algorithm, example the array is 1,2,4,5 ,6,5,7
asked greatest no is 3 then it should print 5, if it asked 2nd greatest no then it should print 6.
Solution

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

void main()
{
int i,j,no[100],n,in,high=0;
clrscr();
printf("enter the no of no");
scanf("%d",&n);
printf("enter the no one by one");
for(i=0;i<n;i++)
scanf("%d",&no[i]);
printf("enter the which high no you need");
scanf("%d",&in);
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
if(no[i]>no[j])

high++;
}
if(high==n-in)
{
break;
}
high=0;
}
printf("the %d big no is %d",in,no[i]);
getch();
}

Output
 
{ Read More }


Write a program to print the sum of the two no in reverse order ?

Problem 
    Find the sum of two no and print their result in reverse order .ex 12+12=24 should be printed as 42
solution

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

void main()
{
int a,b,sum,rsum=0,n;
clrscr();
printf("enter the no1 and no2");
scanf("%d%d",&a,&b);
sum=a+b;
while(sum!=0)
{
n=sum%10;
rsum=rsum*10+n;
sum=sum/10;
}

printf("the near perfect square is %d ",rsum);
getch();
}

Output

{ Read More }


Write a Program to find given no is palindrome or not ?

//Palindrome Program
#include<stdio.h>
#include<conio.h>

void main()
{
int n,no,rno=0,dno;
clrscr();
printf("enter the no");
scanf("%d",&no);
dno=no;
while(no!=0)
{
n=no%10;
rno=rno*10+n;
no=no/10;
}
if(dno==rno)
printf("the %d is palindrome ",dno);
else
printf("the %d is not palindrome",dno);
getch();
}
Output













What is Palindrome number ?
  The no is said to palindrome whose direct view and mirror view are same, example take 121 , whose mirror image is 121  so 121 is palindrome.

if have any doubt , post it on comment
{ Read More }


Sunday, June 23, 2013

Header Files In C

List of Header File available in c is given below(few only)

<aio.h>               <libgen.h>          <spawn.h>                <sys/time.h>
<arpa/inet.h>      <limits.h>            <stdarg.h>                <sys/times.h>
<assert.h>          <locale.h>           <stdbool.h>              <sys/types.h>
<complex.h>      <math.h>             <stddef.h>               <sys/uio.h>
<conio.h>          <monetary.h>       <stdint.h>                <sys/un.h>
<ctype.h>          <mqueue.h>         <stdio.h>                 <sys/utsname.h>
<dirent.h>          <ndbm.h>            <stdlib.h>                <sys/wait.h>
<dlfcn.h>           <net/if.h>              <string.h>                <syslog.h>
<errno.h>          <netdb.h>             <strings.h>              <tar.h>
<fcntl.h>            <netinet/in.h>        <stropts.h>             <termios.h>
<fenv.h>            <netinet/tcp.h>     <sys/ipc.h>              <tgmath.h>
<float.h>            <nl_types.h>        <sys/mman.h>         <time.h>
<fmtmsg.h>        <poll.h>               <sys/msg.h>            <trace.h>
<fnmatch.h>       <pthread.h>         <sys/resource.h>     <ulimit.h>
<ftw.h>              <pwd.h>              <sys/select.h>         <unistd.h>
<glob.h>            <regex.h>             <sys/sem.h>           <utime.h>
<grp.h>             <sched.h>             <sys/shm.h>           <utmpx.h>
<iconv.h>          <search.h>            <sys/socket.h>       <wchar.h>
<inttypes.h>       <semaphore.h>     <sys/stat.h>           <wctype.h>
<iso646.h>        <setjmp.h>           <sys/statvfs.h>        <wordexp.h>
<langinfo.h>       <signal.h>

out of the above mention Header File mostly used Header File at beginning level is
<stdio.h>
<conio.h>
<strings.h>
<math.h>
Hear file <stdio.h>
This header file is  used  in every program because it include the definition of printf, scanf getc,getchar,putc,putchar etc.
see the fig below










we can see that without stdio.h header file , the compiler cannot identify the definition of printf .

Hear file <conio.h>
This header file is  used  in every program because it include the definition of clrscrgetch ,ungetch,putch,gotoxy, etc.
see the image below











we can see that without conio.h header file , the compiler cannot identify the definition of clrscr and getch .

Header file <math.h>
To include the inbuile mathematical function like cos,sine, log, sqrt(square root), we need to
 include the header file <math.h>

header file <string.h>
this header file used for string (sequence of character) hadling,and manipulation like
strlen,strcpy,strcat etc


{ Read More }


C is Structural Programming language , Why ?

C is called structure programming language , because it is strictly restricted to its sructure . anything out of its structure is not accepted .

Structure of C

Header File
Sub Function Declaration
Global variable
main Function Definition
{
Local variable
Content of Main Function
}
Sub Function Definition
{
Local variable
Content of Sub Function
}

Example

#include<stdio.h>
#include<conio.h>
int sum;
void sum(int c,int d);
void main()
{
int a=10,b=20;
clrscr();
sum(a,b);
printf(" The Sum is %d ",sum);
getch();
}
void sum(int c,int d)
{
sum=c+d;
}

The data type int, printf are defined in STDIO header file . STDIO  stands for Standard input and output .
clrscr(); getch() are defined in CONIO header file . CONIO  stands Console Input Output . the Variable SUM is known as Global variable and its scope (lifetime) is throughout program . where as variable a and b is local variable its scope(lifetime) is with that function only . so  in the above Program SUM is used in sub function and Main fuction .

Out of Structure Program 

The program which doesn't follow  the above structure is not accepted by c compiler , it will show an error .
the example of out of structure program is shown below

#include<stdio.h>
#include<conio.h>
void sum(int c,int d);
void main()
{
int a=10,b=20,sum;
clrscr();
sum(a,b);
int s;
s=sum;
printf(" The Sum is %d ",s);
getch();
}
void sum(int c,int d)
{
sum=c+d;
}

In the above program  variable Sum is used in both main as well as subfunction , so it is Global variable , so it should defined below the header file, the variable c is declared in the middle of the program but as per  C structure it should be declared in the beginning . so when above code is compiled by c compiler it show an error
{ Read More }


Thursday, June 20, 2013

First program in C

First program in C
step 1 : open the TC folder (see how to install turbo c)

Step 2: open Bin and then TC . see fig below


Step 3: image c editor (where you will write the program) shown below


Step 4: goto File-> new , you can see the something like below

Step 5: type following Program in the editor
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
printf(" Welcome you  to C4ENGINEERING Blog ");
getch();
}

Step 6: select Run option from menu or ctrl+F9


{ Read More }