#include #include #include char *con(char *s1,char *s2); char *input(); int main() { char *s1,*s2; int i=0; printf(“Enter string 1:”); s1=input(); printf(“Enter string 2:”); s2=input(); // strcat(s1,s2); s1=con(s1,s2); printf(“Concatination is: %s\n”,s1); } char *input() { char *s,ch; int i=0; s=(char *)malloc(sizeof(char)); … Continue reading
1#include<stdio.h> 2 #include<stdlib.h> 3 4 int main() 5 { 6 int *a,i=0,j=0,k,l,m,b,least; 7 a=(int *)malloc(sizeof(int)); 8 9 while(1) 10 { 11 12 printf(“\n\nenter the elements in an array, remember at ’0′ insertion of elements in array will be terminated : … Continue reading
#include int main() { int a[100],i,j,small,n,k; printf(“Enter size of array:”); scanf(“%d”,&n); printf(“Enter element:\n”); for(i=0;i<n;i++) { scanf("%d",&a[i]); } printf("Element and their position are:\n"); for(i=0;i<n;i++) { printf("%d\n",a[i]); } for(i=0;i<n;i++) { small=i; for(j=i;j<n;j++) { if(a[j]<a[small]) small=j; } k=a[small]; a[small]=a[i]; a[i]=k; } printf("Arrar after … Continue reading
#include int main() { char s1[5],s2[5]; int i,j,flag=0; printf(“Enter s1:”); scanf(“%s”,s1); printf(“Enter s2:”); scanf(“%s”,s2); for(i=0;i<5;i++) { if(s1[i]!=s2[i]) { j=s1[i]-s2[i]; flag=1; printf("return value: %d\n",j); break; } } if(flag==0) printf("string matched\n"); return 0; }
header file********************************************************************* #include<stdio.h> #include<stdlib.h> struct distance { int feet; int inches; }; int display(struct distance *,struct distance *,struct distance *); struct distance * add(struct distance *,struct distance *); struct distance * input(); ************************************************************************** main file****************************************************************** #include”header.h” int main() { struct … Continue reading
#include #include int main() { char a[20]={0},b[10]={0}; int i,j=0; printf(“Enter name1:\n”); scanf(“%s”,a); printf(“Enter second name:\n”); scanf(“%s”,b); for(i=0;i<20;i++) { if(a[i]=='') { a[i]=b[j]; j++; } } printf("Concatination is: %s\n",a); return 0; }
operation on link list which i’ve performed: 1.creation of link list, 2.insertion of node a.at begining, b.at end, c.at any position d.at any key value(if a certain element is present then insert this node) 3.traverse on link list 4.searching of … Continue reading
#include #include int main() { char a[20]={0},b[10]={0}; int i,j=0; printf(“Enter name1:\n”); scanf(“%s”,a); printf(“Enter second name:\n”); scanf(“%s”,b); for(i=0;i<20;i++) { if(a[i]=='') { a[i]=b[j]; j++; } } printf("Concatination is: %s\n",a); return 0; }
1 #include<stdio.h> 2 #include<string.h> 3 4 int main() 5 { 6 int n1,n2,i; 7 8 printf(“\n\nfirst enter the number of max. words u will enter in each strings “); 9 printf(“\n\nin first string words u will use are : “); … Continue reading
#include #include int main() { char s1[]=”Amar”,s2[]=”deep rawat”; int i,j; j=strcmp(s1,s2); if(j>0) printf(“S1 is greater than S2\n”); if(j<0) printf("S1 is smaller than s2\n"); strcat(s1,s2); printf("Concatination is:%s\n",s1); i=strlen(s1); printf("Length of string after concatination is:%d\n",i); return 0; }
#include int main() { char p[]=”amardeep singh rawat”; int i=0; int count=0; printf(“String elemen are:\n”); while(p[i]!=”) { printf(“%c\n”,p[i]); i++; count++; } printf(“string is:%s\n”,p); printf(“Length of string is:%d\n”,count); return 0; }
#include int main() { int n,i,a[10]={1,2,3}; printf(“enter element you want to add:”); scanf(“%d”,&n); for(i=9;i>=0;i–) { a[i]=a[i-1]; if(i==0) a[i]=n; // printf(“a[%d]=%d\n”,i,a[i]); } printf(“After adding element:\n”); for(i=0;i<9;i++) { printf("a[%d]=%d\n",i,a[i]); } }
#include int main() { int i,j,k,a[100],n; printf(“Enter size of array:”); scanf(“%d”,&n); printf(“Enter element of an array:”); for(i=0;i<n;i++) { scanf("%d",&a[i]); } for(i=0;i<n;i++) { for(j=0;ja[j+1]) { k=a[j]; a[j]=a[j+1]; a[j+1]=k; } } } printf(“Array after bubble sorting:\n”); for(i=0;i<n;i++) { printf("a[%d]=%d\n",i,a[i]); } }
1 #include<stdio.h> 2 void main() 3 { 4 int i,j,n,n1,n2; 5 6 7 printf(“\n\nenter the number of values u will enter : “); 8 9 scanf(“%d”,&n1); 10 11 int a[n1]; 12 13 printf(“\nnow enter values of elements : \n”); 14 … Continue reading
#include<stdio.h> int main() { int i,j,b,k,n,l; printf(“\n\nenter the number of values u will enter : “); scanf(“%d”,&n); int a[n]; printf(“\nnow enter the elements : \n”); for(l=0;l<n;l++) { scanf(“%d”,&a[l]); } for(i=0;i<n;i++) { for(j=0;j<n-1;j++) { if(a[j]>a[j+1]) { b=a[j]; a[j]=a[j+1]; a[j+1]=b; } } … Continue reading