#include
#include
void main()
{
int i;
char str[10];
printf("Enter sentence: ");
gets(str);
for(i=0;str[i]!='\0';i++)
{
}
printf("The length of the string is %d", i);
}
Sunday, February 15, 2009
Find the Length of and String Arry
Posted by
BADTNC
at
5:49 AM
1 comments
Labels: C Programming
Find Factoral Using Recrusive Funtion
#include
int fact (int);
main()
{
int no, result;
printf("enter number:");
scanf("%d",&no);
result=fact (no);
printf("result is :%d",result);
}
fact (x)
{
int rec;
if(x==0)
return 1;
rec=x*fact(x-1);
return rec;
}
Posted by
BADTNC
at
5:19 AM
0
comments
Labels: C Programming
Find Factoral (normal method)
#include
void main()
{
int i,fac=1,num;
printf("Entet a number");
scanf("%d",&num);
for(i=1;i<=num;i++)
fac=fac*i;
printf("%d",fac);
}
Posted by
BADTNC
at
5:18 AM
0
comments
Labels: C Programming
How t reverse a Int arry
# include
void main()
{
int count,i,m,x,q;
int arr[20];
printf("how many numbers u want to input???");
scanf("%d",&i);
for(m=0 ; m < i; m++ )
{
printf("Enter a number:");
scanf("%d",&arr[m]);
}
for(q=i-1;q>=0;q--)
printf("%d",arr[q]);
}
Posted by
BADTNC
at
4:56 AM
0
comments
Labels: C Programming
How t reverse a string and store it
//How t reverse a string and store it
#include
# include
main()
{
int i,m,n,count;
char str[10],rev_str[10];
printf("Enter a String :");
gets(str);
for(i=0;str[i]!='\0';i++)
{
}
m=i;
int y=0;
i=i-1;
for(i;i>=0;i--)
{
rev_str[y]=str[i];
y++;
}
for(i=0 ; i< m ;i++ )
printf("%c",rev_str[i]);
}
Posted by
BADTNC
at
1:28 AM
0
comments
Labels: C Programming
