mithleshtechno
BAN USERI only believe in coding...
I have good knowledge of C ,data structure,Algorithm,Operating system,DBMS.
#include<stdio.h>
#include<string.h>
//int partition(char * ,int ,int);
void bubble(char *, int );
int main()
{
int i;
char str[100];
char str1[100];
printf("\nENTER THE FIRST STRING:=>");
gets(str);
printf("\n ENTER THE SECOND STRING:=>");
gets(str1);
bubble(str,strlen(str));
bubble(str1,strlen(str1));
printf("%d",strlen(str));
printf("SORTED first ARRAY:=>");
for(i=0;i<strlen(str);i++)
printf("%c->",str[i]);
printf("\n SORTED second ARRAY:=>");
for(i=0;i<strlen(str1);i++)
printf("%c->",str1[i]);
if(strcmp(str1,str)==0)
printf("IMPOSSIBLE");
else
{
for(i=0;i<strlen(str);i++)
{
if(str[i]==str1[i])
continue;
else
{
printf("invalid string");
break;
}
}
}
return 0;
}
void bubble(char *a,int size)
{
int i,j;
char temp;
for(i=0;i<size-1;i++)
{
for(j=0;j<size-1-i;j++)
{
if(a[j]>a[j+1])
{
temp=a[j+1];
a[j+1]=a[j];
a[j]=temp;
}
}
}
}
#include<stdio.h>
int main()
{
int count=0;
int n;
printf("enter the number:=> ");
scanf("%d",&n);
int i,fibo=0;
int previous2=1,previous1=-1;
for(i=0;fibo<n;i++)
{
fibo=previous1+previous2;
if(fibo<=n)
{
count++;
printf("%d ",fibo);
}
else
break;
previous1=previous2;
previous2=fibo;
}
printf("\n");
printf(" the no of term in fibonacii series is :=>:%d",count);
return 0;
}
//Ques=>Write the code to display the series 1 ,2,6,15,31,56....N
#include<stdio.h>
int main()
{
int nofterm,addprevious,i,value ;
addprevious=1;
printf("How many terms do u want to print");
scanf("%d",&nofterm);
for(i=0;i<nofterm;i++)
{
value=addprevious+i*i;
addprevious=value;
printf("%d->", value);
}
return 0;
}
void middlenode(struct node *root)
{
struct node *p,*ptr;
int count1,count2;
count1=0;
count2=0;
root=root->next;
for(ptr=root;ptr;ptr=ptr->next)
{
p=ptr;
count1++;
count2=0;
while(p->next)
{
p=p->next;
count2++;
}
if(count2==count1)
{
printf("MIDDLE NODE IS %d",ptr->info);
break;
}
if(count1>count2)
{
printf("NO MIDDLE NODE IS EXISTING");
break;
}
}
}
#include<stdio.h>
#include<string.h>
int main()
{
char str[6][9]={"ABCW", "BAZ", "FOO", "BAR", "XTFN", "ABCDEF"};
int i,j,l,m,count,max,max1,firstlength,secondlength;
count=0;
max=0;
max1=0;
char *firstptr,*secondptr;
for(i=0;i<5;i++)
{
for(j=i+1;j<6;j++)
{
firstptr=&str[i];
secondptr=&str[j];
firstlength=strlen(firstptr);
secondlength=strlen(secondptr);
count=0;
for(l=0;l<firstlength;l++)
{
for(m=0;m<secondlength;m++)
{
if(firstptr[l]!=secondptr[m])
continue;
else
{
count++;
break;
}
}
if(count==1)
break;
}
if(count==0)
{
max=firstlength*secondlength;
if(max>max1)
max1=max;
}
}
}
printf("MAXIMUM VALUE OF length(s) * length(t) :=> %d",max1);
return 0;
}
#include<stdio.h>
int powerof2(int);
int main()
{
int num,endindex,k,sum=0;
int array[55],i,i1,j=0;
int check;
printf("enter the number between 1 and 109 :=>");
scanf("%d",&num);
check =powerof2(num);
if(check==0)
printf("IMPOSSIBLE");
else
{
if(num%2>0)
{
++num;
num=num/2;
printf("%d %d ",num,num-1);
}
else
{
for(i=0;i<num/2;i++)
{
array[i]=++j;
//printf("%d",array[i]);
}
endindex=i;
k=i;
while(1)
{
sum=sum+array[k--];
if(sum>num)
{
endindex--;
k=endindex;
sum=0;
}
if(sum==num)
break;
}
for(i1=++k;i1<=endindex;i1++)
printf(" %d ->",array[i1]);
}
}
return 0;
}
int powerof2(int num)
{
int i=2;
while(i<num)
{
i=i*2;
}
if(i==num)
return 0;
else
return 1;
}
#include<stdio.h>
int main()
{
int i=0;
char ch[4] ={'a','b','c','\0'};
int *ptr;
for(i=0;i<3;i++)
{
ptr=((int*)&ch[i]);
printf("%c ",*ptr);
}
return 0;
}
int main()
{
int *p=malloc(0);
*p=56;
printf("%d",*p);
return 0;
}
malloc return the void pointer and we know void pointer can be assigned in any kind of pointer without typecasting .
so here pointer p store the address of void pointer which returned by malloc, and at that address you are performing write operation by storing value 56,that's why it print 56.
#include<stdio.h>
#include<conio.h>
int main()
{
int a[10];
int n,c,index,i,temp;
c=1;
printf(" enter the size of array:=>");
scanf("%d",&n);
printf(" enter the element of array :=>");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(i=0;i<n;i++)
{
if(a[i]>0 && c>0)
{
index=i;
temp=a[i];
c--;
}
else
{
if(a[i]==0 && c==0)
{
a[index]=a[i];
a[i]=temp;
index++;
temp=a[index];
}
}
}
printf(" now required array :=>");
for(i=0;i<n;i++)
printf("%d ",a[i]);
return 0;
}
void fun(int *a,int n)
{
int c1,c2,temp,temp1,index,index1,j,i;
c1=0;
c2=0;
for(j=0;j<n;j++)
{
if(a[j]%2==0 && (j+1)%2==0)
continue;
else
{
if(a[j]%2>0 && (j+1)%2>0)
continue;
else
{
if(a[j]%2==0)
{
c1++;
temp=a[j];
index=j;
if(c2>0)
{
a[index1]=a[j];
a[j]=temp1;
c2=0;
}
}
else
{
c2++;
temp1=a[j];
index1=j;
if(c1>0)
{
a[index]=a[j];
a[j]=temp;
c1=0;
}
}
}
}
}
printf(" now required array:=>");
for(i=0;i<n;i++)
printf("%d ",a[i]);
}
#include<stdio.h>
#include<conio.h>
int main()
{
int a,b,count=0,n,rem,cons1;
float count2=0.1,cons;
printf("enter the value of a and b:=>");
scanf("%d%d",&a,&b);
printf(" enter the value of N:=> ");
scanf("%d",&n);
while(n>0)
{
if(count==0)
{
cons=a/b;
rem=a%b;
count++;
}
cons1=(rem*10)/b;
cons=cons+cons1*count2;
rem=(rem*10)%b;
count2=count2*0.1;
n--;
}
printf("%f",cons);
return 0;
}
#include<stdio.h>
#include<conio.h>
#include<string.h>
int main()
{
char str[10],str1[19];
int len,i,j,k,l;
printf(" enter the string:=>");
scanf("%s",str);
len=strlen(str);
for(i=0;i<len-1;i++)
{
for(j=0;j<=i;j++)
str1[j]=str[j];
str1[j]=str[len-1];
str1[++j]='\0';
printf("\n");
for(l=0;l<i+2;l++)
{
if(l==i+1)
printf("%d",len-(i+2));
printf("%c",str1[l]);
}
if(i>0)
{
int m,len2;
len2=len-2;
printf("\n");
for(m=0;m<i;m++)
{
printf("%c",str[m]);
}
printf("%d",len-(i+2));
for(j=0;j<2;j++)
printf("%c",str[len2++]);
}
}
return 0;
}
Reproseyasalazar, Animator at Achieve Internet
I have strong english language skills and communication skills.Good written and oral communication skills.I collect knowledge of Best ...
int main()
- mithleshtechno February 18, 2016{
int arr[5]={-2,5,-1,7,-3};
int i,j,k,counter,sum,l,m,temp;
temp=0;
int n;
for(i=0;i<5;i++)
{
counter=-1;
for(j=0;j<=i;j++)
{
counter++;
k=counter;
sum=0;
for(l=0;l<5-i;l++)
{
sum=sum+arr[k];
k=k+1;
}
printf("%d",sum);
if(sum>temp)
{
temp=sum;
}
}
}
printf(" biggest sum from give array:=>%d",temp);
return 0;
}