├── Basics ├── 1.c ├── 10.c ├── 11.c ├── 12.c ├── 13.c ├── 14.c ├── 15.c ├── 16.c ├── 17.c ├── 18.c ├── 19.c ├── 2.c ├── 20.c ├── 21.c ├── 22.c ├── 23.c ├── 24.c ├── 25.c ├── 26.c ├── 27.c ├── 28.c ├── 29.c ├── 3.c ├── 30.c ├── 31.c ├── 32.c ├── 33.c ├── 4.c ├── 5.c ├── 6.c ├── 7.c ├── 8.c └── 9.c ├── Hard ├── 75.c ├── 76.c ├── 77.c ├── 78.c ├── 79.c ├── 80.c ├── 81.c ├── 82.c ├── 83.c ├── 85.c ├── 86.c ├── 87.c ├── 88.c ├── 89.c ├── 90.c ├── 91.c ├── 92.c ├── 93.c ├── 94.c ├── 95.c ├── 96.c ├── 97.c └── a.out ├── LICENSE ├── Moderate ├── 34.c ├── 35.c ├── 36.c ├── 37.c ├── 38.c ├── 39.c ├── 40.c ├── 41.c ├── 42.c ├── 43.c ├── 44.c ├── 45(Pending).c ├── 46(Pending).c ├── 47.c ├── 48.c ├── 49.c ├── 50.c ├── 51.c ├── 52.c ├── 53.c ├── 54.c ├── 55(Pending).c ├── 56.c ├── 57.c ├── 58(Pending).c ├── 59.c ├── 60_pending.c ├── 61.c ├── 62.c ├── 63.c ├── 64.c ├── 65.c ├── 66.c ├── 67.c ├── 68.c ├── 69.c ├── 70.c ├── 71.c ├── 72.c ├── 73.c ├── 74.c └── a.out └── README.md /Basics/1.c: -------------------------------------------------------------------------------- 1 | //Program to print "Hello World" 2 | #include 3 | int main() 4 | { 5 | printf("Hello World"); 6 | } 7 | -------------------------------------------------------------------------------- /Basics/10.c: -------------------------------------------------------------------------------- 1 | //Program to check whether the number is even or add 2 | #include 3 | int main() 4 | { 5 | int n; 6 | printf("Enter the number\t"); 7 | scanf("%d",&n); 8 | if(n%2==0) 9 | { 10 | printf("The Number is Even\t"); 11 | } 12 | else 13 | printf("The Number is Odd\t"); 14 | } 15 | -------------------------------------------------------------------------------- /Basics/11.c: -------------------------------------------------------------------------------- 1 | //Program to accept three numbers from user and print them in ascending and descending order 2 | #include 3 | int main() 4 | { 5 | int a,b,c; 6 | printf("Enter three numbers\t"); 7 | scanf("%d\n%d\n%d",&a,&b,&c); 8 | if(a>=b && a>=c) 9 | { 10 | if(b>=c) 11 | { 12 | printf("Descending order\t%d\t%d\t%d",a,b,c); 13 | printf("\nAscending order\t%d\t%d\t%d",c,b,a); 14 | } 15 | else 16 | { 17 | printf("Descending order \t%d\t%d\t%d",a,c,b); 18 | printf("\nAscending order\t%d\t%d\t%d",b,c,a); 19 | } 20 | } 21 | else if(b>=a && b>=c) 22 | { 23 | if(a>=c) 24 | { 25 | printf("Descending order\t%d\t%d\t%d",b,a,c); 26 | printf("\nAscending order\t%d\t%d\t%d",c,a,b); 27 | } 28 | else 29 | { 30 | printf("Descending order\t%d\t%d\t%d",b,c,a); 31 | printf("\nAscending order\t%d\t%d\t%d",a,c,b); 32 | } 33 | } 34 | else 35 | { 36 | if(b>=a) 37 | { 38 | printf("Descending order\t%d\t%d\t%d",c,b,a); 39 | printf("Ascending order\t%d\t%d\t%d",a,b,c); 40 | } 41 | else 42 | { 43 | printf("Descending order\t%d\t%d\t%d",c,a,b); 44 | printf("Ascending order\t%d\t%d\t%d",b,a,c); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Basics/12.c: -------------------------------------------------------------------------------- 1 | //Program to find the roots of a quardratic equation. 2 | #include 3 | int main() 4 | { 5 | int a,b,c; 6 | float r1,r2,det; 7 | printf("Enter the cofficients of a,b,c\t"); 8 | scanf("%d\n%d\n%d",&a,&b,&c); 9 | det=(b*b)-(4*a*c); 10 | if(det>0) 11 | { 12 | r1=(-b+(sqrt(det)))/(2*a); 13 | r2=(-b-(sqrt(det)))/(2*a); 14 | printf("Roots are %f and %f",r1,r2); 15 | } 16 | else 17 | { 18 | r1=r2=-b/(2*a); 19 | printf("Roots are %f and %f",r1,r2); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Basics/13.c: -------------------------------------------------------------------------------- 1 | //Program to accept rollnumber and marks of three subjects from user and print total marks, average and grade. 2 | #include 3 | int main() 4 | { 5 | int rollno,total=0,i; 6 | int *marks; 7 | float avg; 8 | char grade; 9 | marks=(int *)malloc(3*sizeof(int)); 10 | printf("Enter the roll number\t"); 11 | scanf("%d",&rollno); 12 | printf("Enter the Marks of three subjects\n"); 13 | for(i=0;i<3;i++) 14 | { 15 | scanf("%d",&marks[i]); 16 | total+=marks[i]; 17 | } 18 | avg=total/3; 19 | if(avg>90) 20 | { 21 | grade='O'; 22 | } 23 | else if(avg>80) 24 | { 25 | grade='A'; 26 | } 27 | else if(avg>70) 28 | { 29 | grade='B'; 30 | } 31 | else if(avg>50) 32 | { 33 | grade='c'; 34 | } 35 | else 36 | { 37 | grade='D'; 38 | } 39 | 40 | printf("\nReg No.\tTotal\tAverage\tGrade\n%d\t%d\t%.2f\t%c",rollno,total,avg,grade); 41 | free(marks); 42 | } 43 | -------------------------------------------------------------------------------- /Basics/14.c: -------------------------------------------------------------------------------- 1 | //Program to print numbers from 1 to n using while loop. 2 | #include 3 | int main() 4 | { 5 | int n,i=1; 6 | printf("Enter the value of N\t"); 7 | scanf("%d",&n); 8 | while(i<=n) 9 | { 10 | printf("%d\n",i); 11 | i++; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Basics/15.c: -------------------------------------------------------------------------------- 1 | //Program to print numbers from n to 1 using Do While loop. 2 | #include 3 | int main() 4 | { 5 | int n,i=1; 6 | printf("Enter the value of N\t"); 7 | scanf("%d",&n); 8 | do{ 9 | printf("%d\n",i); 10 | i++; 11 | }while(i<=n); 12 | } 13 | -------------------------------------------------------------------------------- /Basics/16.c: -------------------------------------------------------------------------------- 1 | //Program to print first n even numbers. 2 | #include 3 | int main() 4 | { 5 | int n; 6 | int i=2; 7 | printf("Enter the value of N\t"); 8 | scanf("%d",&n); 9 | printf("The First %d even numbers are\n",n); 10 | while(i<=(2*n)) 11 | { 12 | printf("%d\n",i); 13 | i=i+2; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Basics/17.c: -------------------------------------------------------------------------------- 1 | //Program to accept a number and print that number in reverse order. 2 | //Ex:- 1024 3 | //Output:- 4201 4 | #include 5 | int main() 6 | { 7 | int n; 8 | printf("Enter the number\t"); 9 | scanf("%d",&n); 10 | while(n>0) 11 | { 12 | printf("%d",n%10); 13 | n/=10; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Basics/18.c: -------------------------------------------------------------------------------- 1 | // Program to accept a number and print sum of it’s digits 2 | #include 3 | int main() 4 | { 5 | int n,total=0,rem; 6 | printf("Enter the number\t"); 7 | scanf("%d",&n); 8 | while(n>0) 9 | { 10 | rem=n%10; 11 | total+=rem; 12 | n/=10; 13 | } 14 | printf("The Sum of the digits are %d",total); 15 | } 16 | -------------------------------------------------------------------------------- /Basics/19.c: -------------------------------------------------------------------------------- 1 | //Program to take a number from user and check whether it is Armstrong number or not. 2 | #include 3 | int main() 4 | { 5 | int n,temp,rem,total=0; 6 | printf("Enter the number\t"); 7 | scanf("%d",&n); 8 | temp=n; 9 | while(n>0) 10 | { 11 | rem=n%10; 12 | total+=(rem*rem*rem); 13 | n/=10; 14 | } 15 | (total==temp)?printf("Armstrong Number\n"):printf("Not an Armstrong Number\n"); 16 | } 17 | 18 | -------------------------------------------------------------------------------- /Basics/2.c: -------------------------------------------------------------------------------- 1 | //Program to assign values of two numbers and print their addition 2 | #include 3 | int main() 4 | { 5 | int a=5,b=10; 6 | printf("%d",a+b); 7 | } 8 | 9 | -------------------------------------------------------------------------------- /Basics/20.c: -------------------------------------------------------------------------------- 1 | //Program to take number from user and print table of that number. 2 | #include 3 | int main() 4 | { 5 | int n,i; 6 | printf("Enter the table number\t"); 7 | scanf("%d",&n); 8 | for(i=1;i<=100;i++) 9 | { 10 | printf("%d*%d=%d\n",i,n,i*n); 11 | } 12 | } 13 | 14 | -------------------------------------------------------------------------------- /Basics/21.c: -------------------------------------------------------------------------------- 1 | //Program to accept number and print it's factorial. 2 | #include 3 | int main() 4 | { 5 | int n,value=1,i; 6 | printf("Enter the Value of N\t"); 7 | scanf("%d",&n); 8 | for(i=n;i>0;i--) 9 | { 10 | value*=i; 11 | } 12 | printf("The Factorial of %d is %d",n,value); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /Basics/22.c: -------------------------------------------------------------------------------- 1 | // Program to accept number and print if it is prime number or not. 2 | #include 3 | int main() 4 | { 5 | int n,i,flag=1; 6 | printf("Enter the value of N\t"); 7 | scanf("%d",&n); 8 | for(i=2;i<=n/2;i++) 9 | { 10 | if(n%i==0) 11 | { 12 | flag=0; 13 | printf("\nNot a prime number"); 14 | break; 15 | } 16 | } 17 | if(flag==1) 18 | { 19 | printf("\nPrime Number"); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Basics/23.c: -------------------------------------------------------------------------------- 1 | //Program to print 'n' prime numbers. 2 | #include 3 | int main() 4 | { 5 | int n,i,j,flag=1,count=0; 6 | printf("Enter the value of N\t"); 7 | scanf("%d",&n); 8 | for(i=2;count!=n;i++) 9 | { 10 | flag=1; 11 | for(j=2;j<=i/2;j++) 12 | { 13 | if(i%j==0) 14 | { 15 | flag=0; 16 | break; 17 | } 18 | } 19 | if(flag==1) 20 | { 21 | count++; 22 | printf("%d\n",i); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Basics/24.c: -------------------------------------------------------------------------------- 1 | // Program to accept a number and print Fibonacci sequence. 2 | #include 3 | int main() 4 | { 5 | int n,a=0,b=1,c,i; 6 | printf("Enter the value of N\t"); 7 | scanf("%d",&n); 8 | printf("0\n1\n"); 9 | for(i=2;i 3 | int main() 4 | { 5 | int i,n,temp,sum=0; 6 | printf("Enter the value of N\t"); 7 | scanf("%d",&n); 8 | for(i=0;i 3 | int main() 4 | { 5 | int n,i; 6 | int total=0; 7 | int *array; 8 | printf("Enter the value of N\t"); 9 | scanf("%d",&n); 10 | array=(int *)malloc(n*sizeof(int)); 11 | for(i=0;i 3 | int main() 4 | { 5 | int n,sum=0; 6 | printf("Enter the Number\t"); 7 | scanf("%d",&n); 8 | while(n>0) 9 | { 10 | sum=sum+(n%10); 11 | n/=10; 12 | } 13 | printf("The Sum of Digits of the Number is %d",sum); 14 | } 15 | -------------------------------------------------------------------------------- /Basics/28.c: -------------------------------------------------------------------------------- 1 | // Program to accept a number and add the digits of that number using recursion. 2 | #include 3 | int total(int n); 4 | int main() 5 | { 6 | int n; 7 | printf("Enter the value of N\t"); 8 | scanf("%d",&n); 9 | printf("%d",total(n)); 10 | } 11 | int total(int num) 12 | { 13 | static sum=0; 14 | if(num==0) 15 | { 16 | return 0; 17 | } 18 | else 19 | { 20 | return num%10 + total(num/10); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Basics/29.c: -------------------------------------------------------------------------------- 1 | //Average of numbers. 2 | #include 3 | int main() 4 | { 5 | int n,i,temp; 6 | float sum=0.0; 7 | printf("Enter total Numbers\t"); 8 | scanf("%d",&n); 9 | printf("Enter %d Numbers\n",n); 10 | for(i=0;i 3 | int main() 4 | { 5 | int a,b; 6 | printf("Enter Two values\n"); 7 | scanf("%d\n%d",&a,&b); 8 | printf("The sum is \t%d",a+b); 9 | } 10 | -------------------------------------------------------------------------------- /Basics/30.c: -------------------------------------------------------------------------------- 1 | //Program to calculate Square of 'n' numbers. 2 | #include 3 | int main() 4 | { 5 | int n,i; 6 | printf("Enter the value of N\t"); 7 | scanf("%d",&n); 8 | printf("The First %d Square Numbers are\n",n); 9 | for(i=1;i<=n;i++) 10 | { 11 | printf("\nThe Square of %d is %d",i,i*i); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Basics/31.c: -------------------------------------------------------------------------------- 1 | //Program to take an alphabet from user and check whether it is a vowel or not. 2 | #include 3 | int main() 4 | { 5 | char a; 6 | printf("Enter the Char\t"); 7 | scanf("%c",&a); 8 | if(a=='A' || a=='a' || a=='E' || a=='e' || a=='I' || a=='i' || a=='O' || a=='o' || a=='U' || a=='u') 9 | { 10 | printf("\n%c is a vowel",a); 11 | } 12 | else 13 | printf("\n%c is not a vowel",a); 14 | } 15 | -------------------------------------------------------------------------------- /Basics/32.c: -------------------------------------------------------------------------------- 1 | //Program to take two numbers and check whether they are amicable numbers or not. 2 | #include 3 | int main() 4 | { 5 | int a,b,i,sum=0; 6 | printf("Enter the two numbers\n"); 7 | scanf("%d\t%d",&a,&b); 8 | for(i=1;i 3 | int main() 4 | { 5 | int i,n; 6 | printf("Enter the value of N\t"); 7 | scanf("%d",&n); 8 | printf("The Factors are\n"); 9 | for(i=1;i 3 | int main() 4 | { 5 | float p,r; 6 | int n; 7 | printf("Enter the Principle value\t"); 8 | scanf("%f",&p); 9 | printf("Enter No, of years\t"); 10 | scanf("%d",&n); 11 | printf("Enter Rate of interest\t"); 12 | scanf("%f",&r); 13 | printf("The Simple Interest\t%f",(p*n*r)/100); 14 | } 15 | -------------------------------------------------------------------------------- /Basics/5.c: -------------------------------------------------------------------------------- 1 | //Program to accept value of radius and print area of a circle 2 | #include 3 | int main() 4 | { 5 | int r; 6 | printf("Enter the radius of the circle\t"); 7 | scanf("%d",&r); 8 | printf("The Area of a circle\t%f",(3.14*r*r)); 9 | } 10 | -------------------------------------------------------------------------------- /Basics/6.c: -------------------------------------------------------------------------------- 1 | //Program to accept a number from user and print it's square & cube 2 | #include 3 | int main() 4 | { 5 | int n; 6 | printf("Enter the number\t"); 7 | scanf("%d",&n); 8 | printf("The Square of %d is %d\nThe Cube of %d is %d\n",n,(n*n),n,(n*n*n)); 9 | } 10 | -------------------------------------------------------------------------------- /Basics/7.c: -------------------------------------------------------------------------------- 1 | //Program to accept two values of a & b and swap their values 2 | #include 3 | int main() 4 | { 5 | int a,b,temp; 6 | printf("Enter two number\n"); 7 | scanf("%d\n%d",&a,&b); 8 | printf("The Value before swapped is %d\t%d\n",a,b); 9 | temp=a; 10 | a=b; 11 | b=temp; 12 | printf("The Value after swapped is %d\t%d\n",a,b); 13 | } 14 | -------------------------------------------------------------------------------- /Basics/8.c: -------------------------------------------------------------------------------- 1 | //Program to accept two number and print largest among them 2 | #include 3 | int main() 4 | { 5 | int a,b; 6 | printf("Enter Two Numbers\n"); 7 | scanf("%d\n%d",&a,&b); 8 | (a>b)?printf("The largest number is \t%d",a):printf("The largest number is \t%d",b); 9 | } 10 | -------------------------------------------------------------------------------- /Basics/9.c: -------------------------------------------------------------------------------- 1 | //Program to accept a number and check whether the number is positive, negative or zero 2 | #include 3 | int main() 4 | { 5 | int n; 6 | printf("Enter the Number\t"); 7 | scanf("%d",&n); 8 | if(n>0) 9 | { 10 | printf("The Number is positive\n"); 11 | } 12 | else if(n==0) 13 | { 14 | printf("The Number is zero\n"); 15 | } 16 | else 17 | printf("The Number is negative\n"); 18 | 19 | } 20 | 21 | -------------------------------------------------------------------------------- /Hard/75.c: -------------------------------------------------------------------------------- 1 | //Program to reverse the string 2 | #include 3 | int main() 4 | { 5 | char string[100]; 6 | char *i,*k; 7 | char temp; 8 | printf("Enter the string\t"); 9 | gets(string); 10 | for(i=string,k=string + strlen(string)-1;k>i;++i,--k) 11 | { 12 | *i=*i^*k; 13 | *k=*k^*i; 14 | *i=*i^*k; 15 | } 16 | printf("\nThe reversed string is %s",string); 17 | 18 | 19 | } 20 | -------------------------------------------------------------------------------- /Hard/76.c: -------------------------------------------------------------------------------- 1 | //Program to reverse the string using pointer 2 | #include 3 | int main() 4 | { 5 | char string[100],*p; 6 | int i; 7 | printf("Enter the string\t"); 8 | gets(string); 9 | p=string; 10 | for(i=0;i=0;i--) 13 | printf("%c",*p--); 14 | 15 | 16 | 17 | 18 | } 19 | -------------------------------------------------------------------------------- /Hard/77.c: -------------------------------------------------------------------------------- 1 | //Program to sort the strings 2 | #include 3 | int main() 4 | { 5 | char string[20][20],temp[20]; 6 | int i,n,j; 7 | printf("Enter no. of the string"); 8 | scanf("%d",&n); 9 | for(i=0;i0) 16 | { 17 | strcpy(temp,string[i]); 18 | strcpy(string[i],string[j]); 19 | strcpy(string[j],temp); 20 | } 21 | } 22 | 23 | } 24 | for(i=0;i 3 | int main() 4 | { 5 | char string1[20],string2[20]; 6 | char *temp; 7 | printf("Enter the first string\t"); 8 | gets(string1); 9 | printf("\nEnter the second string\t"); 10 | gets(string2); 11 | if(strlen(string1)>strlen(string2)) 12 | temp=(char*)malloc((strlen(string1)+1)*sizeof(char)); 13 | else 14 | temp=(char*)malloc((strlen(string2)+1)*sizeof(char)); 15 | printf("\nBefore Swapping\t%s and %s",string1,string2); 16 | strcpy(temp,string1); 17 | strcpy(string1,string2); 18 | strcpy(string2,temp); 19 | printf("\nAfter Swapping \t%s and %s",string1,string2); 20 | free(temp); 21 | } 22 | -------------------------------------------------------------------------------- /Hard/79.c: -------------------------------------------------------------------------------- 1 | //Program to add two matrix 2 | #include 3 | int main() 4 | { 5 | int first_matrix[50][100],second_matrix[50][100]; 6 | int rows,columns,i,j; 7 | printf("Enter the rows and columns of first matrix\t"); 8 | scanf("%d\t%d",&rows,&columns); 9 | printf("Enter the value for first matrix\n"); 10 | for(i=0;i 3 | int main() 4 | { 5 | int *array; 6 | int i,j,n,flag=1,temp; 7 | printf("Enter the number of elements\t"); 8 | scanf("%d",&n); 9 | array=(int *)malloc(n*sizeof(int)); 10 | printf("Enter the elements\n"); 11 | for(i=0;i=0 && flag;i--) 14 | { 15 | flag=0; 16 | for(j=0;j<=i-1;j++) 17 | { 18 | if(array[j]>array[j+1]) 19 | { 20 | temp=array[j]; 21 | array[j]=array[j+1]; 22 | array[j+1]=temp; 23 | flag=1; 24 | } 25 | } 26 | } 27 | printf("The Elements in Ascending order\n"); 28 | for(i=0;i 3 | int main() 4 | { 5 | int array[10][10]; 6 | int m,n,count=0; 7 | printf("Enter number of rows and columns\t"); 8 | scanf("%d\t%d",&m,&n); 9 | printf("Enter the matrix values\n"); 10 | for(i=0;i(m+n)/2)?printf("Sparse Matrix with %d zeros",count):printf("Not a Sparse matrix with %d non zeros",(m*n)-count); 20 | } 21 | -------------------------------------------------------------------------------- /Hard/82.c: -------------------------------------------------------------------------------- 1 | //Program to delete given element from array 2 | #include 3 | int main() 4 | { 5 | int *array; 6 | int i,j,n,element,flag=0; 7 | printf("Enter the number of element\t"); 8 | scanf("%d",&n); 9 | array=(int *)malloc(n*sizeof(int)); 10 | for(i=0;i 3 | int main() 4 | { 5 | int *array; 6 | int i,j,n,position; 7 | printf("Enter the size of the element\t"); 8 | scanf("%d",&n); 9 | array=(int *)malloc(n*sizeof(int)); 10 | for(i=0;i(n+1)) 17 | { 18 | printf("Please enter the valid position\t"); 19 | } 20 | else 21 | { 22 | for(i=position-1;i 3 | int main() 4 | { 5 | int i,j,determinant; 6 | int array[3][3]; 7 | printf("Enter the element of the matrix\n"); 8 | for(i=0;i<3;i++) 9 | { 10 | for(j=0;j<3;j++) 11 | { 12 | scanf("%d",&array[i][j]); 13 | } 14 | } 15 | determinant = (array[0][0] * ((array[1][1]*array[2][2])-(array[1][2]*array[2][1]))) - (array[1][0] * ((array[0][1]*array[2][2]) - (array[0][2]*array[2][1]))) + (array[2][0] * ((array[0][1]* array[1][2])- (array[1][1]*array[0][2]))); 16 | printf("The Determinant value is %d",determinant); 17 | } 18 | -------------------------------------------------------------------------------- /Hard/86.c: -------------------------------------------------------------------------------- 1 | //Program to find Largest and Smallest number in array 2 | #include 3 | int main() 4 | { 5 | int *array; 6 | int i,max=0,min=999,n; 7 | printf("Enter the number of elements in an array\t"); 8 | scanf("%d",&n); 9 | array=(int *)malloc(n * sizeof(int)); 10 | for(i=0;imax) 14 | max=array[i]; 15 | else if(array[i] 3 | int main() 4 | { 5 | int *array; 6 | int i,j,n; 7 | printf("Enter the size of the array\t"); 8 | scanf("%d",&n); 9 | array=(int *)malloc(n* sizeof(int)); 10 | for(i=0;i=0;i++,j--) 15 | { 16 | if(i 3 | int main() 4 | { 5 | int *array; 6 | int position,n,element,i; 7 | printf("Enter the number of element\t"); 8 | scanf("%d",&n); 9 | array=(int *)malloc((n+1)*sizeof(int)); 10 | for(i=0;in) 19 | printf("\nPlease enter the valid position\n"); 20 | else 21 | { 22 | for(i=n-1;i>=position-1;i--) 23 | { 24 | array[i+1]=array[i]; 25 | } 26 | array[position-1]=element; 27 | } 28 | for(i=0;i<=n;i++) 29 | { 30 | printf("%d",array[i]); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Hard/89.c: -------------------------------------------------------------------------------- 1 | //Program to sort array using Insertion sort 2 | #include 3 | int main() 4 | { 5 | int n,*array,i,j,flag=1; 6 | printf("Enter number of elements\t"); 7 | scanf("%d",&n); 8 | array=(int *)malloc(n*sizeof(int)); 9 | for(i=0;i=0 && flag;i--) 12 | { 13 | flag=0; 14 | for(j=0;jarray[j+1]) 17 | { 18 | flag=1; 19 | array[j]=array[j]^array[j+1]; 20 | array[j+1]=array[j]^array[j+1]; 21 | array[j]=array[j]^array[j+1]; 22 | } 23 | } 24 | } 25 | printf("The Sorted Array using inserting sort is \n"); 26 | for(i=0;i 3 | int main() 4 | { 5 | int n,*array,element,i; 6 | printf("Enter the number of elements\t"); 7 | scanf("%d",&n); 8 | array=(int *)malloc(n*sizeof(int)); 9 | for(i=0;i=l) 23 | { 24 | 25 | int mid=l+(r-l)/2; 26 | if(array[mid]==element) 27 | return mid; 28 | if(array[mid]>element) 29 | return binarysearch(array,l,mid-1,element); 30 | return binarysearch(array,mid+1,r,element); 31 | } 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /Hard/91.c: -------------------------------------------------------------------------------- 1 | //Multiplication of two Matrices 2 | #include 3 | int main() 4 | { 5 | int m,n,q,p,i,j,k,matrix1[10][10],matrix2[10][10],result[10][10]; 6 | printf("\nEnter the number of rows and columns in first matrix\t"); 7 | scanf("%d\t%d",&m,&n); 8 | printf("\nEnter the number of rows and columns in second matrix\t"); 9 | scanf("%d\t%d",&p,&q); 10 | if(n==p) 11 | { 12 | printf("Enter the values for first matrix\n"); 13 | for(i=0;i 3 | char stack[40]; 4 | int top=-1; 5 | void push(char c); 6 | char pop(); 7 | int main() 8 | { 9 | char str[20]; 10 | int i; 11 | //printf("Enter the expression"); 12 | scanf("%s",str); 13 | printf("%s",str); 14 | for(i=0;str[i]!='\0';i++) 15 | { 16 | if(str[i]=='(' || str[i]=='[' || str[i]=='{') 17 | push(str[i]); 18 | else if(str[i]==')' || str[i]==']' || str[i]=='}') 19 | { 20 | if(strcmp(pop(),str[i])) 21 | { 22 | printf("\nPlease enter the correct expression\n"); 23 | break; 24 | } 25 | } 26 | } 27 | if(i==strlen(str) && top==-1) 28 | { 29 | printf("\nBalanced\n"); 30 | } 31 | } 32 | void push(char c) 33 | { 34 | if(top!=40) 35 | { 36 | strcpy(stack[top++],c); 37 | } 38 | } 39 | char pop() 40 | { 41 | if(top!=-1) 42 | return stack[top--]; 43 | } 44 | 45 | -------------------------------------------------------------------------------- /Hard/93.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int main() 4 | { 5 | char input_string[100]; 6 | int mid,i,k,j; 7 | scanf("%s",input_string); 8 | mid=strlen(input_string)/2; 9 | for(i=1;i<=strlen(input_string);i++) 10 | { 11 | int temp=(i*2)-1,count=0; 12 | for(j=2*strlen(input_string)-1;j>=i;j--) 13 | { 14 | if(abs(temp)==j) 15 | { 16 | for(k=temp;count=7) 19 | { 20 | printf("%c",input_string[(mid+count)%10]); 21 | } 22 | else 23 | { 24 | printf("%c",input_string[(mid+count)%strlen(input_string)]); 25 | } 26 | count++; 27 | } 28 | } 29 | } 30 | printf("\n"); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Hard/94.c: -------------------------------------------------------------------------------- 1 | /*Given an integer array, write a function to reverse every set of 'k' numbers. Modify the same array without creating another array. Reverse the remaining elements even if it is less than 'k'. 2 | 3 | Example: 4 | Input: {2, 1 , 3 , 5 , 8 , 6 , 7 , 9} and k = 3 5 | Output: {3 , 1 , 2 , 6 , 8 , 5 , 9 , 7}*/ 6 | #include 7 | int main() 8 | { 9 | int n,*input_array,i,k; 10 | printf("Enter the array size\t"); 11 | scanf("%d",&n); 12 | input_array=(int *)malloc(n*sizeof(int)); 13 | printf("Enter the elements\n"); 14 | for(i=0;i 12 | int main() 13 | { 14 | char input_string[20],char_array[20]; 15 | int i,int_array[20],int_count=0,char_count=0; 16 | scanf("%s",input_string); 17 | for(i=0;input_string[i];i++) 18 | { 19 | if(input_string[i]>=48 && input_string[i]<=57) 20 | { 21 | int_array[int_count++]=input_string[i]-'0'; 22 | } 23 | else 24 | { 25 | char_array[char_count++]=input_string[i]; 26 | } 27 | } 28 | if(int_count==char_count+1) 29 | { 30 | int value=int_array[0]; 31 | for(i=0;i 12 | int main() 13 | { 14 | int size_1,size_2,*first_array,*second_array,*result_array,i,j,pointer1,pointer2,flag1=0,flag2=0,k=0; 15 | printf("Enter the size of array 1\t"); 16 | scanf("%d",&size_1); 17 | first_array=(int *)malloc(size_1*sizeof(int)); 18 | printf("Enter the first array elements\n"); 19 | for(i=0;ifirst_array[size_1-1]) 33 | { 34 | pointer1=size_1; 35 | flag1=1; //flag 1 means descending array 36 | } 37 | else 38 | { 39 | pointer1=0; 40 | flag1=0; 41 | } 42 | if(second_array[0]>second_array[size_2-1]) 43 | { 44 | pointer2=size_2; 45 | flag2=1; 46 | } 47 | else 48 | { 49 | pointer2=0; 50 | flag2=0; 51 | } 52 | 53 | printf("First array minimum value %d\n",pointer1); 54 | printf("Second array minimum value %d\n",pointer2); 55 | if(flag1==0 && flag2==0) 56 | { 57 | for(i=pointer1,j=pointer2;isecond_array[j]) 65 | { 66 | result_array[k]=second_array[j]; 67 | j++;k++; 68 | } 69 | else 70 | { 71 | result_array[k]=second_array[j]; 72 | i++; 73 | j++; 74 | k++; 75 | } 76 | } 77 | } 78 | else if(flag1==1 && flag2==0) 79 | { 80 | for(i=pointer1,j=pointer2;i>=0 && jsecond_array[j]) 88 | { 89 | result_array[k]=second_array[j]; 90 | j++;k++; 91 | } 92 | else 93 | { 94 | result_array[k]=second_array[j]; 95 | i--; 96 | j++; 97 | k++; 98 | } 99 | } 100 | } 101 | for(i=0;i 12 | int main() 13 | { 14 | int n,*input_array,i,j; 15 | printf("Enter the value of N\t"); 16 | scanf("%d",&n); 17 | input_array=(int *)malloc(n*sizeof(int)); 18 | for(i=0;iinput_array[j]) 29 | { 30 | input_array[i]=input_array[i]+input_array[j]-(input_array[j]=input_array[i]); 31 | } 32 | } 33 | else 34 | { 35 | if(input_array[i] 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /Moderate/34.c: -------------------------------------------------------------------------------- 1 | //Program to accept two integer numbers and print the GCD(Greatest Common Divisor) 2 | #include 3 | int main() 4 | { 5 | int a,b,max=100,i; 6 | printf("Enter the value of a and b\n"); 7 | scanf("%d\t%d",&a,&b); 8 | if(a>b) 9 | max=a; 10 | else 11 | max=b; 12 | for(i=max;i>=1;i--) 13 | { 14 | if(a%i==0 && b%i==0) 15 | { 16 | printf("The GCD of two numbers are \t%d",i); 17 | break; 18 | } 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /Moderate/35.c: -------------------------------------------------------------------------------- 1 | // Program to find power of number. 2 | #include 3 | int main() 4 | { 5 | int a,b,i,value=1; 6 | printf("Enter the base value\t"); 7 | scanf("%d",&a); 8 | printf("Enter the exponent value\t"); 9 | scanf("%d",&b); 10 | for(i=0;i 3 | int main() 4 | { 5 | int a,b,x,y,temp; 6 | printf("Enter two numbers\n"); 7 | scanf("%d\t%d",&a,&b); 8 | x=a; 9 | y=b; 10 | while(y!=0) 11 | { 12 | temp=y; 13 | y=x%y; 14 | x=temp; 15 | } 16 | printf("The HCF of %d and %d are %d\n",a,b,x); 17 | printf("The LCM of %d and %d are %d\n",a,b,(a*b)/x); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /Moderate/37.c: -------------------------------------------------------------------------------- 1 | //Program to find largest among 3 numbers using ternary operator. 2 | #include 3 | int main() 4 | { 5 | int a,b,c,x; 6 | printf("Enter the three numbers\n"); 7 | scanf("%d\t%d\t%d",&a,&b,&c); 8 | x=(a>b)?((a>c)?a:c):((b>c)?b:c); 9 | printf("The Largest of three numbers are %d",x); 10 | } 11 | -------------------------------------------------------------------------------- /Moderate/38.c: -------------------------------------------------------------------------------- 1 | //Program to find largest number of 'n' numbers. 2 | #include 3 | int main() 4 | { 5 | int n,max=0,i; 6 | int *a; 7 | printf("Enter the value of N\t"); 8 | scanf("%d",&n); 9 | a=(int *)malloc(n*sizeof(int)); 10 | for(i=0;imax) 14 | { 15 | max=a[i]; 16 | } 17 | } 18 | free(a); 19 | printf("The Largest Number among %d numbers are %d",n,max); 20 | } 21 | -------------------------------------------------------------------------------- /Moderate/39.c: -------------------------------------------------------------------------------- 1 | //Program to check whether the number is neon number or not. 2 | #include 3 | int main() 4 | { 5 | int n,temp,sum=0; 6 | printf("Enter the number\t"); 7 | scanf("%d",&n); 8 | temp=n*n; 9 | while(temp>0) 10 | { 11 | sum+=(temp%10); 12 | temp/=10; 13 | } 14 | (sum==n)?printf("Neon Number\n"):printf("Not a Neon Number\n"); 15 | } 16 | -------------------------------------------------------------------------------- /Moderate/40.c: -------------------------------------------------------------------------------- 1 | //Program to check Niven number (Harshad number) 2 | #include 3 | int main() 4 | { 5 | int n,temp,sum=0; 6 | printf("Enter the number\t"); 7 | scanf("%d",&n); 8 | temp=n; 9 | while(n>0) 10 | { 11 | sum+=(n%10); 12 | n/=10; 13 | } 14 | (temp%sum==0)?printf("Harshed Or Niven Number\n"):printf("Not a Harshed or Niven Number\n"); 15 | } 16 | -------------------------------------------------------------------------------- /Moderate/41.c: -------------------------------------------------------------------------------- 1 | // Program to check whether the number is palindrome or not 2 | #include 3 | int main() 4 | { 5 | int n,temp,num=0; 6 | printf("Enter the Number\t"); 7 | scanf("%d",&n); 8 | temp=n; 9 | while(n>0) 10 | { 11 | num*=10; 12 | num+=(n%10); 13 | n/=10; 14 | } 15 | (temp==num)?printf("Palindrome\n"):printf("Not a Palindrome\n"); 16 | } 17 | -------------------------------------------------------------------------------- /Moderate/42.c: -------------------------------------------------------------------------------- 1 | //Program to check perfect number 2 | #include 3 | int main() 4 | { 5 | int n,i,sum=0; 6 | printf("Enter the number\t"); 7 | scanf("%d",&n); 8 | for(i=1;i 3 | int main() 4 | { 5 | int n; 6 | printf("Enter the Number\t"); 7 | scanf("%d",&n); 8 | printf("The Squar root of %d is %.2f",n,sqrt(n)); 9 | } 10 | -------------------------------------------------------------------------------- /Moderate/44.c: -------------------------------------------------------------------------------- 1 | //Program to print sum of 'n' prime numbers 2 | #include 3 | int main() 4 | { 5 | int n,count=0,i,j,sum=0; 6 | printf("Enter the N value\t"); 7 | scanf("%d",&n); 8 | for(i=2;count<=n;i++) 9 | { 10 | for(j=2;j<=i-1;j++) 11 | { 12 | if(i%j==0) 13 | { 14 | break; 15 | } 16 | } 17 | if(j==i) 18 | { 19 | count++; 20 | sum+=i; 21 | } 22 | if(count==n) 23 | break; 24 | } 25 | printf("The Sum of first %d prime numbers are\t%d",n,sum); 26 | } 27 | -------------------------------------------------------------------------------- /Moderate/45(Pending).c: -------------------------------------------------------------------------------- 1 | // Program to print sum of factorial series 1/1! + 2/2! +...1/N! 2 | #include 3 | int main() 4 | { 5 | int n; 6 | } 7 | -------------------------------------------------------------------------------- /Moderate/46(Pending).c: -------------------------------------------------------------------------------- 1 | //Program to calculate the sum of 'n' terms in Taylor series.(77) 2 | -------------------------------------------------------------------------------- /Moderate/47.c: -------------------------------------------------------------------------------- 1 | // Program to swap two numbers without using third variable 2 | #include 3 | int main() 4 | { 5 | int n,a,b; 6 | printf("Enter the numbers a and b\n"); 7 | scanf("%d\t%d",&a,&b); 8 | printf("The Values before swapping are %d and %d",a,b); 9 | a=a+b; 10 | b=a-b; 11 | a=a-b; 12 | printf("\nThe Values after swapping are %d and %d",a,b); 13 | } 14 | -------------------------------------------------------------------------------- /Moderate/48.c: -------------------------------------------------------------------------------- 1 | //Program to swap two numbers using bitwise XOR. 2 | #include 3 | int main() 4 | { 5 | int a,b; 6 | printf("Enter two numbers\n"); 7 | scanf("%d\t%d",&a,&b); 8 | printf("The Values before swapping are %d and %d",a,b); 9 | a=a^b; 10 | b=a^b; 11 | a=a^b; 12 | printf("\nThe Values after swapping are %d and %d",a,b); 13 | } 14 | -------------------------------------------------------------------------------- /Moderate/49.c: -------------------------------------------------------------------------------- 1 | //Program to swap two numbers using pointer 2 | #include 3 | int main() 4 | { 5 | int a,b; 6 | int *ptr1,*ptr2,*temp; 7 | printf("Enter two numbers\n"); 8 | scanf("%d\t%d",&a,&b); 9 | printf("The Value before swapping are %d and %d",a,b); 10 | ptr1=&a; 11 | ptr2=&b; 12 | *temp=*ptr1; 13 | *ptr1=*ptr2; 14 | *ptr2=*temp; 15 | printf("\nThe Value after swapping are %d and %d",a,b); 16 | 17 | 18 | } 19 | -------------------------------------------------------------------------------- /Moderate/50.c: -------------------------------------------------------------------------------- 1 | //Program to add two numbers using pointer 2 | #include 3 | int main() 4 | { 5 | int a,b,sum=0; 6 | int *ptr1,*ptr2; 7 | printf("Enter two numbers\n"); 8 | scanf("%d\t%d",&a,&b); 9 | ptr1=&a; 10 | ptr2=&b; 11 | sum=(*ptr1)+(*ptr2); 12 | printf("The Sum of two numbers %d and %d are %d",a,b,sum); 13 | } 14 | -------------------------------------------------------------------------------- /Moderate/51.c: -------------------------------------------------------------------------------- 1 | //Program to add first and last digit of a number. 2 | #include 3 | int main() 4 | { 5 | int n,sum=0,second; 6 | printf("Enter the number\t"); 7 | scanf("%d",&n); 8 | sum=n%10; 9 | while(n>0) 10 | { 11 | second=n%10; 12 | n/=10; 13 | } 14 | printf("\nThe sum of first and last digit is %d",sum+second); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /Moderate/52.c: -------------------------------------------------------------------------------- 1 | // Program to find area of triangle using Heron's formula. 2 | #include 3 | int main() 4 | { 5 | int a,b,c,s; 6 | printf("Enter tthe three sides of the triangle\n"); 7 | scanf("%d\t%d\t%d",&a,&b,&c); 8 | s=(a+b+c)/2; 9 | printf("\nThe Area of triangle is %.2f",sqrt(s*(s-a)*(s-b)*(s-c))); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /Moderate/53.c: -------------------------------------------------------------------------------- 1 | //Program to convert Binary to Decimal. 2 | #include 3 | int main() 4 | { 5 | int n,k=0,sum=0,rem; 6 | printf("Enter the binary number\t"); 7 | scanf("%d",&n); 8 | while(n>0) 9 | { 10 | rem=n%10; 11 | sum+=(rem *pow(2,k)); 12 | k++; 13 | n/=10; 14 | } 15 | printf("\nThe Decimal value is %d",sum); 16 | } 17 | -------------------------------------------------------------------------------- /Moderate/54.c: -------------------------------------------------------------------------------- 1 | //Program to convert Decimal numbers to Binary 2 | #include 3 | int main() 4 | { 5 | int n,c,k; 6 | printf("Enter the Decimal Number\t"); 7 | scanf("%d",&n); 8 | printf("The Binary Notation of %d is\t",n); 9 | for(c=7;c>=0;c--) 10 | { 11 | k=n>>c; 12 | (k&1)?printf("1"):printf("0"); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Moderate/55(Pending).c: -------------------------------------------------------------------------------- 1 | //Program to find f(x) by Lagrange's interpolation method. 2 | #include 3 | int main() 4 | { 5 | int 6 | } 7 | -------------------------------------------------------------------------------- /Moderate/56.c: -------------------------------------------------------------------------------- 1 | // Program to check the leap year. 2 | #include 3 | int main() 4 | { 5 | int n; 6 | printf("Enter the year\t"); 7 | scanf("%d",&n); 8 | (n%4==0 || n%400==0)?printf("A leap year\n"):printf("Not a leap year\n"); 9 | 10 | } 11 | -------------------------------------------------------------------------------- /Moderate/57.c: -------------------------------------------------------------------------------- 1 | //Program to find nCr & nPr 2 | #include 3 | int factorial(int n); 4 | int result=1; 5 | int main() 6 | { 7 | int n,r; 8 | long ncr,npr; 9 | printf("Enter the value of n and r\n"); 10 | scanf("%d\t%d",&n,&r); 11 | npr=factorial(n)/factorial(n-r); 12 | ncr=factorial(n)/(factorial(n-r)*factorial(r)); 13 | printf("The ncr and npr are %ld and %ld",ncr,npr); 14 | 15 | } 16 | int factorial(int n) 17 | { 18 | int i; 19 | result=1; 20 | for(i=n;i>=1;i--) 21 | { 22 | result*=i; 23 | } 24 | return result; 25 | } 26 | -------------------------------------------------------------------------------- /Moderate/58(Pending).c: -------------------------------------------------------------------------------- 1 | //Program for Newton Raphson General 2 | #include 3 | 4 | -------------------------------------------------------------------------------- /Moderate/59.c: -------------------------------------------------------------------------------- 1 | // Program to calculate the sum of even numbers from 1 to n. 2 | #include 3 | int main() 4 | { 5 | int n,i,sum=0; 6 | printf("Enter the value of N\t"); 7 | scanf("%d",&n); 8 | for(i=2;i<=n;i=i+2) 9 | { 10 | sum+=i; 11 | } 12 | printf("The Sum of even numbers from 1 to n is %d",sum); 13 | } 14 | -------------------------------------------------------------------------------- /Moderate/60_pending.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ratheshprabakar/C-Complete-practice/6868777d2e4bf56713d17e358f96bb542817419c/Moderate/60_pending.c -------------------------------------------------------------------------------- /Moderate/61.c: -------------------------------------------------------------------------------- 1 | // Program to add two strings without using concat() function 2 | #include 3 | int main() 4 | { 5 | char string1[50],string2[100]; 6 | int i,index; 7 | printf("Enter the first string\t"); 8 | gets(string1); 9 | printf("Enter the second string\t"); 10 | gets(string2); 11 | index=strlen(string1); 12 | for(i=0;i 3 | int main() 4 | { 5 | char string[100]; 6 | int i,count=0; 7 | printf("Enter the string\t"); 8 | gets(string); 9 | for(i=0;string[i]!='\0';i++) 10 | { 11 | if(string[i]=='a'||string[i]=='e' || string[i]=='i' || string[i]=='e' || string[i]=='u' || string[i]=='A' || string[i]=='E' || string[i]=='I' || string[i]=='O' || string[i]=='U') 12 | count++; 13 | } 14 | printf("Number of vowels in the string %s is %d",string,count); 15 | } 16 | -------------------------------------------------------------------------------- /Moderate/63.c: -------------------------------------------------------------------------------- 1 | // Program to compare two strings 2 | #include 3 | int main() 4 | { 5 | char string1[100],string2[100]; 6 | printf("Enter the first string\t"); 7 | gets(string1); 8 | printf("Enter the second string\t"); 9 | gets(string2); 10 | (!strcmp(string1,string2))?printf("\nTwo Strings are equal\n"):printf("\nTwo strings are not equal\n"); 11 | 12 | } 13 | -------------------------------------------------------------------------------- /Moderate/64.c: -------------------------------------------------------------------------------- 1 | // Program to compare strings without using strcmp() function. 2 | #include 3 | int main() 4 | { 5 | char string1[100],string2[100]; 6 | int i; 7 | printf("Enter the first string\t"); 8 | gets(string1); 9 | printf("Enter the second string\t"); 10 | gets(string2); 11 | if(strlen(string1)==strlen(string2)) 12 | { 13 | for(i=0;i 3 | int main() 4 | { 5 | char string1[100]; 6 | int i; 7 | printf("Enter the string\t"); 8 | gets(string1); 9 | for(i=0;i=65 && string1[i]<=90) 12 | string1[i]=string1[i]+32; 13 | } 14 | printf("The string is \t%s",string1); 15 | } 16 | -------------------------------------------------------------------------------- /Moderate/66.c: -------------------------------------------------------------------------------- 1 | //Program to copy char array / copy string. 2 | #include 3 | int main() 4 | { 5 | char string1[100],temp_string[100]; 6 | printf("Enter the string\t"); 7 | gets(string1); 8 | strcpy(temp_string,string1); 9 | printf("The Copied string is \t%s",temp_string); 10 | } 11 | -------------------------------------------------------------------------------- /Moderate/67.c: -------------------------------------------------------------------------------- 1 | //Program to copy string without using strcpy() function. 2 | #include 3 | int main() 4 | { 5 | char string1[100]; 6 | char *temp_string; 7 | int i; 8 | printf("Enter the string\t"); 9 | scanf("%s",string1); 10 | temp_string=(char *)malloc((strlen(string1)+1)*sizeof(char)); 11 | for(i=0;i 3 | int main() 4 | { 5 | char string[100]; 6 | int i; 7 | int *count; 8 | printf("Enter the string\t"); 9 | gets(string); 10 | count=(int *)malloc(27*sizeof(int)); 11 | for(i=0;i 3 | int main() 4 | { 5 | char string[100]; 6 | int i,caps=0,small=0; 7 | printf("Enter the string\t"); 8 | gets(string); 9 | for(i=0;i=65 && string[i]<=90) 12 | caps++; 13 | else if(string[i]>=97 && string[i]<=122) 14 | small++; 15 | } 16 | printf("\nThe string %s contains %d uppercase and %d lowercase letters",string,caps,small); 17 | } 18 | -------------------------------------------------------------------------------- /Moderate/70.c: -------------------------------------------------------------------------------- 1 | //Program to calculate the length of string 2 | #include 3 | int main() 4 | { 5 | char string[100]; 6 | printf("Enter the string\t"); 7 | gets(string); 8 | printf("\nThe Length of the string is \t%d",strlen(string)); 9 | } 10 | -------------------------------------------------------------------------------- /Moderate/71.c: -------------------------------------------------------------------------------- 1 | //Program to calculate the length of string without using strlen() function 2 | #include 3 | int main() 4 | { 5 | char string[100]; 6 | int i; 7 | printf("Enter the string\t"); 8 | gets(string); 9 | for(i=0;string[i]!='\0';i++); 10 | printf("The Length of the string is \t%d ",i); 11 | } 12 | -------------------------------------------------------------------------------- /Moderate/72.c: -------------------------------------------------------------------------------- 1 | //Program to check the palindrome of string 2 | #include 3 | int main() 4 | { 5 | char string[100]; 6 | int i,j; 7 | printf("Enter the string\t"); 8 | gets(string); 9 | for(i=0,j=strlen(string)-1;i 3 | int main() 4 | { 5 | char string[100]; 6 | int i,j; 7 | printf("Enter the string\t"); 8 | gets(string); 9 | for(i=0,j=strlen(string)-1;i 3 | int main() 4 | { 5 | char string[100]; 6 | int i,j=0; 7 | printf("Enter the string\t"); 8 | gets(string); 9 | for(i=0;i!=strlen(string);i++) 10 | { 11 | if(string[i] !=' ') 12 | string[j++]=string[i]; 13 | } 14 | string[j]='\0'; 15 | printf("Your string is\t%s",string); 16 | } 17 | -------------------------------------------------------------------------------- /Moderate/a.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ratheshprabakar/C-Complete-practice/6868777d2e4bf56713d17e358f96bb542817419c/Moderate/a.out -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # C-Complete-practice 2 | This repository will contains C programs from beginners to advance level. This will help the newbie to learn the programming from basics. I made over the plan, follow this path to explore yourself in the basic language C :) 3 | 4 | 5 | **Basics :** 6 | * [Program to print "Hello World!!"](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Basics/1.c) 7 | * [Program to assign values of two numbers and print their addition](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Basics/2.c) 8 | * [Program to accept values of two numbers and print their addition](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Basics/3.c) 9 | * [Program to print simple interest](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Basics/4.c) 10 | * [Program to accept value of radius and print area of a circle](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Basics/5.c) 11 | * [Program to accept a number from user and print it’s square & cube](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Basics/6.c) 12 | * [Program to accept two values of a & b and swap their values](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Basics/7.c) 13 | * [Program to accept two number and print largest among them](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Basics/8.c) 14 | * [Program to accept a number and check whether the number is Positive, Negative or Zero](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Basics/9.c) 15 | * [Program to check whether the number is even or odd](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Basics/10.c) 16 | * [Program to accept three numbers from user and print them in ascending and decending order](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Basics/11.c) 17 | * [ Program to find the roots of a quadratic equation](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Basics/12.c) 18 | * [Program to accept rollnumber and marks of three subjects from user and print total marks, average and grade](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Basics/13.c) 19 | * [Program to print numbers from 1 to n using while loop](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Basics/14.c) 20 | * [Program to print numbers from n to 1 using Do While loop](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Basics/15.c) 21 | * [Program to print first n even numbers](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Basics/16.c) 22 | * [Program to accept a number and print that number in reverse order.Ex:- 1024 23 | Output:- 4201](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Basics/17.c) 24 | * [Program to accept a number and print sum of it’s digits](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Basics/18.c) 25 | * [Program to take a number from user and check whether it is Armstrong number or not](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Basics/19.c) 26 | * [Program to take number from user and print table of that number](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Basics/20.c) 27 | * [Program to accept number and print it's factorial](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Basics/21.c) 28 | * [Program to accept number and print if it is prime number or not](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Basics/22.c) 29 | * [Program to print 'n' prime numbers](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Basics/23.c) 30 | * [Program to accept a number and print Fibonacci sequence](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Basics/24.c) 31 | * [Add 'n' numbers](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Basics/25.c) 32 | * [Add 'n' numbers using array](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Basics/26.c) 33 | * [Program to accept a number and add the digits of that number](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Basics/27.c) 34 | * [Program to accept a number and add the digits of that number using recursion](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Basics/28.c) 35 | * [Average of numbers](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Basics/29.c) 36 | * [Program to calculate Square of 'n' numbers](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Basics/30.c) 37 | * [Program to take an alphabet from user and check whether it is a vowel or not](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Basics/31.c) 38 | * [Program to take two numbers and check whether they are amicable numbers or not](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Basics/32.c) 39 | * [Program to accept a number and print the factors of that number](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Basics/33.c) 40 | 41 | **Moderate :** 42 | 43 | * [ Program to accept two integer numbers and print the GCD(Greatest Common Divisor)](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Moderate/34.c) 44 | * [Program to find power of number](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Moderate/35.c) 45 | * [Program to calculate HCF & LCM](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Moderate/36.c) 46 | * [Program to find largest among 3 numbers using ternary operator](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Moderate/37.c) 47 | * [Program to find largest number of 'n' numbers](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Moderate/38.c) 48 | * [Program to check whether the number is neon number or not](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Moderate/39.c) 49 | * [Program to check Niven number (Harshad number)](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Moderate/40.c) 50 | * [Program to check whether the number is palindrome or not](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Moderate/41.c) 51 | * [Program to check perfect number.](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Moderate/42.c) 52 | * [Program to find the square root of a number](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Moderate/43.c) 53 | * [Program to print sum of 'n' prime numbers](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Moderate/44.c) 54 | * [Program to swap two numbers without using third variable](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Moderate/47.c) 55 | * [Program to swap two numbers using bitwise XOR](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Moderate/48.c) 56 | * [Program to swap two numbers using pointer](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Moderate/49.c) 57 | * [Program to add two numbers using pointer](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Moderate/50.c) 58 | * [Program to add first and last digit of a number](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Moderate/51.c) 59 | * [Program to find area of triangle using Heron's formula](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Moderate/52.c) 60 | * [Program to convert Binary to Decimal](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Moderate/53.c) 61 | * [Program to convert Decimal numbers to Binary](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Moderate/54.c) 62 | * [Program to check the leap year](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Moderate/56.c) 63 | * [Program to find nCr & nPr](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Moderate/57.c) 64 | * [Program to calculate the sum of even numbers from 1 to n](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Moderate/59.c) 65 | * [Program to add two strings without using concat() function](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Moderate/61.c) 66 | * [Program to check vowels in string](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Moderate/62.c) 67 | * [Program to compare two strings](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Moderate/63.c) 68 | * [Program to compare strings without using strcmp() function](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Moderate/64.c) 69 | * [Program to convert string from uppercase to lowercase](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Moderate/65.c) 70 | * [Program to copy char array / copy string](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Moderate/66.c) 71 | * [Program to copy string without using strcpy() function](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Moderate/67.c) 72 | * [Program to count frequency of characters in a string](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Moderate/68.c) 73 | * [Program to count total number of uppercase and lowercase in a string](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Moderate/69.c) 74 | * [Program to calculate the length of string](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Moderate/70.c) 75 | * [Program to calculate the length of string without using strlen() function](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Moderate/71.c) 76 | * [Program to check the palindrome of string](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Moderate/72.c) 77 | * [Program to check the palindrome of word using array](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Moderate/73.c) 78 | * [Program to remove white space in string](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Moderate/74.c) 79 | 80 | **Hard** 81 | 82 | * [Program to reverse the string](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Hard/75.c) 83 | * [Program to reverse the string using pointer](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Hard/76.c) 84 | * [Program to sort the strings](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Hard/77.c) 85 | * [Program to swap two strings](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Hard/78.c) 86 | * [Program to add two matrix](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Hard/79.c) 87 | * [Program to arrange array numbers in ascending order](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Hard/80.c) 88 | * [Program to check whether the matrix is sparse matrix or not](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Hard/81.c) 89 | * [Program to delete an element from array](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Hard/82.c) 90 | * [Program to delete given number from array](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Hard/83.c) 91 | * [Program to calculate the determinant of 2×2 matrix](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Hard/84.c) 92 | * [Program to calculate the determinant of 3×3 matrix](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Hard/85.c) 93 | * [Program to find Largest and Smallest number in array](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Hard/86.c) 94 | * [Program to reverse the array](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Hard/87.c) 95 | * [Program to insert an element in array at particular position](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Hard/88.c) 96 | * [Program to sort array using Insertion sort](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Hard/89.c) 97 | * [Search an element in a sorted array using Binary Search](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Hard/90.c) 98 | * [Given an integer array, write a function to reverse every set of 'k' numbers. Modify the same array without creating another array. Reverse the remaining elements even if it is less than 'k'. 99 | Example: 100 | Input: {2, 1 , 3 , 5 , 8 , 6 , 7 , 9} and k = 3 101 | Output: {3 , 1 , 2 , 6 , 8 , 5 , 9 , 7}](https://github.com/Ratheshprabakar/C-Complete-practice/blob/master/Hard/94.c) 102 | --------------------------------------------------------------------------------