MY OWN PROJECTS


VERY BIG CODE FOR USING  

"ARRAYS,STRINGS"

 FULL CODES





#include<stdio.h> #include<conio.h> #include<string.h> main() { int a[20],b[20][20],c[20][20],d[20][20],e[20][20][20],i,j,k,h,m,n,o,p,q,r,x,y,tp,ca,hr=0,kl,alp=0,wrd=0,lns=0,sp=0,tooth; char s[60][60],str1[60],str2[60],ha,nu[60]; clrscr(); for(i=0;i<80;i++) printf("*"); printf("Main Menu\n Press 'a'. program with arrays \n Press 's'. program with strings\n press e. for exit\n"); scanf("%c",&ha); switch(ha) { case 'a': { printf("\n Sub Menu \n Press 1.Program with 1-dimension array \n Press 2.Program with 2-dimension array \n Press 3.Program with 3-dimension array\n"); printf("Enter your choice\n"); scanf("%d",&x); switch(x) { case 1: { printf("You have selected the choice of Program with 1-dimension array\n"); printf("Press 1.For printing numbers which u have entered is sorted\n"); printf("Press 2.For searching any number in the numbers u have entered\n"); printf("Press 3.For insert any number in any place from index to yor choice\n"); scanf("%d",&h); switch(h) { case 1: { printf("\nPress 1.For Assendingly printing numbers\n 2.For desendingly printing numbers\n"); scanf("%d",&ca); printf("how many nubers u want to arrang \n"); scanf("%d",&y); printf("Enter any %d of numbers\n",y); for(i=0;i<y;i++) scanf("%d",&a[i]); printf("the numbers which u entered before sorting is: \n"); for(i=0;i<y;i++) printf("%d \t",a[i]); if (ca==1) { for(i=0;i<y;i++) for(j=i+1;j<y;j++) if (a[i]>a[j]) { tp=a[i];a[i]=a[j];a[j]=tp; } printf("\n After the sorting the numbers are:\n"); for(i=0;i<y;i++) printf("%d\t",a[i]); getch(); exit(0); } else if (ca==2) { for(i=0;i<y;i++) for(j=i+1;j<y;j++) if(a[i]<a[j]) { tp=a[i];a[i]=a[j];a[j]=tp; } printf("\n After the sorting the numbers are:\n"); for(i=0;i<y;i++) printf("%d\t",a[i]); getch(); exit(0); } else printf("Wrong Choice"); getch(); exit(0); case 2: { printf("how many numbers u want to use\n"); scanf("%d",&y); printf("Now enters any %d numbers:\n",y); for(i=0;i<y;i++) scanf("%d",&a[i]); printf("Enter any number to search :\n"); scanf("%d",&tp); for(i=0;i<y;i++) if(a[i]==tp) { hr=1; break; } if(hr==1) printf("yes!! number %d is present \n",tp); else printf("Number not found\n"); getch(); exit(0);} case 3: { printf("how many numbers u want to use\n"); scanf("%d",&y); printf("Enter any %d numbers\n",y); for(i=0;i<y;i++) scanf("%d",&a[i]); printf("The numbers you have entered is\n"); for(i=0;i<y;i++) printf("%d\t",a[i]); printf("\n Enter the location in above order: \n"); scanf("%d",&ca); printf("\n Enter the new Value in that location:\n"); scanf("%d",&tp); printf("\nThe numbers before sorting\n"); for(i=0;i<y;i++) printf("%d\t",a[i]); for(i=y-1;i>=ca;i--) a[i+1]=a[i]; a[ca]=tp; printf("\n\n After sorting is :"); for(i=0;i<=y;i++) printf("%d\t",a[i]); getch(); exit(0); } } default: printf("Wrong Choice"); getch(); exit(0); }} case 2: { printf("You have selected the choice 2-dimension array\n"); printf("Another Menu\n Press 1.Addition of matrix\n 2.Subtraction of matrix\n 3.multiplication of matrix\n 4.transpose of matrix\n"); scanf("%d",&x); printf("Enter the row and coloum size of selected matrix:\t"); scanf("%d%d",&m,&n); printf("Enter %d by %d of elements in selected matrix\n",m,n); for(i=0;i<m;i++) for(j=0;j<n;j++) scanf("%d",&b[i][j]); switch(x) { case 1: { printf("Enter the size of Row and coloum of second matrix\n"); scanf("%d%d",&p,&q); if(m!=p&&n!=q) { printf("The matrix corrdination for addition imposible for disorder\n"); getch(); exit(0); } else { printf("Enter %d by %d elements of elements in second matrix\n",p,q); for(i=0;i<m;i++) for(j=0;j<n;j++) scanf("%d",&c[i][j]); for(i=0;i<m;i++) for(j=0;j<n;j++) d[i][j]=b[i][j]+c[i][j]; printf("After the Addition of two matrixs\n"); for(i=0;i<m;i++) { for(j=0;j<n;j++) { printf("%d\t",d[i][j]); } printf("\n"); } getch(); exit(0); } case 2: { printf("Enter the size of row and coloum of second matrix\n"); scanf("%d%d",&p,&q); if ((m!=p)||(n!=q)) { printf("the matrix cordination for subtraction imposible for disorder\n"); getch(); exit(1); } printf("Enter %d by %d of elements for second matrix \n",p,q); for(i=0;i<m;i++) for(j=0;j<n;j++) scanf("%d",&c[i][j]); for(i=0;i<m;i++) for(j=0;j<n;j++) d[i][j]=b[i][j]-c[i][j]; printf("After the subtraction of two matrices\n"); for(i=0;i<m;i++) { for(j=0;j<n;j++) { printf("%d\t",d[i][j]); } printf("\n"); } getch(); exit(0); } } case 3: { printf("Enter the size of row and coloum of second matrix\n"); scanf("%d%d",&p,&q); if (n!=p) { printf("Multiplication cannot possible for disorder of two matices\n"); getch(); exit(0); } else { printf("Enter the %d by %d of rows and cooums of second matrix\n",p,q); for(i=0;i<p;i++) for(j=0;j<q;j++) scanf("%d",&c[i][j]); printf("After the multiplication \n"); for(i=0;i<m;i++) for(j=0;j<q;j++) { d[i][j]=0; for(k=0;k<n;k++) d[i][j] +=b[i][j]*c[j][i]; } for(i=0;i<m;i++) { for(j=0;j<n;j++) printf("%d \t",d[i][j]); printf("\n"); } getch(); exit(0); } case 4: { if(m!=n) { printf("Matrix transpose imposible because of disorder"); getch(); exit(0); } else printf("Matrix of before transpose is:\n"); for(i=0;i<m;i++) { for(j=0;j<n;j++) printf("%d\t",b[i][j]); printf("\n"); } printf("After the transpose of matrix\n"); for(i=0;i<m;i++) { for(j=0;j<n;j++) { c[i][j]=b[j][i]; printf("%d\t",c[i][j]); } printf("\n"); } } default: printf("Wrong choice"); getch(); exit(0); } } case 3: { printf("Enter the size of tabel,row,coloum to print\n"); scanf("%d%d%d",&m,&n,&o); printf("now enter the elements in linearly\n"); for(i=0;i<m;i++) { for(j=0;j<n;j++) for(k=0;k<o;k++) scanf("%d",&e[i][j][k]); } printf("The 3-d array of h\n"); for(i=0;i<m;i++) { printf("The table h of: %d\n",i+1); for(j=0;j<n;j++) { for(k=0;k<o;k++) printf("%d\t",e[i][j][k]); printf("\n"); } printf("\n"); } getch(); exit(0); } } default: printf("Wrong choice"); getch(); exit(0); } } case 's': { printf("Sub-Menu\n"); printf("Press 1.String Copy\n 2.String comparision\n 3.String concatenation \n 4.String length \n 5.String Programes\n"); scanf("%d",&x); switch(x) { case 1: { printf("Enter any string of number 1.to copy it from one memroy location to another location\n"); gets(str1); printf("Enter another string of number 2. to over write on first string\n"); gets(str2); strcpy(str1,str2); printf("Afetr the string copying of 2 to 1 is : %s",str1); getch(); exit(0); } case 2: { printf("Enter any string of a\n"); gets(str1); printf("Now Enter another string of b\n"); gets(str2); n=strcmp(str1,str2); printf("After the comparision of string a to b is :%d",n); getch(); exit(0); } case 3: { printf("Enter any string of number a\n"); gets(str1); printf("Enter another string of number b\n"); gets(str2); strcat(str1,str2); printf("After the string concatination the string of a to b is: %s",str1); getch(); exit(0); } case 4: { printf("Enter any string to find its length \n"); gets(str1); n=strlen(str1); printf("The length of string is %d",n); getch(); exit(0); } case 5: { printf("Multi Inner Sub-Menu\n"); printf("Press 1.program with pallendrome\n2.program to count total string\n3.program to search for name\n"); scanf("%d",&y); switch(y) { case 1: { printf("Enter any string to check it is pallendrome or not\n"); gets(str1); strcpy(str2,str1); strrev(str2); if (strcmp(str2,str1)==0); { printf("Entered string of %s is Pallendrome",str1); } { printf("Entered string of %s not pallendrome",str1); } getch(); exit(0); } case 2: { printf("Enter any sentence of strings and press '*' to terminete\n"); scanf("%[^*]s",str1); for(i=0;str1[i]!='\0';i++) { if((str1[i]>='A')&&(str1[i]<='Z')||(str1[i]>='a')&&(str1[i]<='z')) alp++; else if ((str1[i]==' ')||(str1[i]=='\n')) wrd++; else if (str1[i]=='\n') lns++; else sp++; } printf("Charecters :%d\n",i); printf("Words :%d\n",wrd); printf("Alphabates :%d\n",alp); printf("Lines :%d\n",lns); getch(); exit(0); } case 3: { printf("Enter how many names u want \n"); scanf("%d",&n); printf("Now enter the names of %d persons\n",n); for(i=0;i<n;i++) scanf("%s",str1[i]); printf("Enter the name to search\n"); scanf("%s",str2); tooth=0; for(i=0;i<n;i++) if (strcmp(str1[i],str2)==0) { tooth=1; break; } if(tooth) printf("Entered name of %s is found\n",str2); else printf("Entered name of %s not found\n",str2); getch(); exit(0); } default: { printf("Wrong Choice\n"); getch(); exit(0); } } } default:{ printf("Wrong choice"); getch(); exit(0); } } }}}














  SMALL  WORK  OF "ADDITION & 

 TERMINATION



#include<stdio.h> #include<conio.h> main() { int n,y,x,m,i; char c,t,l; clrscr(); expand: { printf("enter x and y\n"); scanf("%d%d",&x,&y); n=x+y; printf("the value is %d\n",n); printf("Press 't' to terminate\n"); scanf("%ch",&l); goto expand; if(l=='t') getch(); }}







FINDING AVERAGE  MARKS  OF  A  STUDENT



#include<stdio.h> #include<conio.h> void avgcaluclation() { int m1,m2,m3,m4,m5,m6,total; float avg; char s[20]; clrscr(); printf("Enter The Name Of The Student \n"); scanf("%s",s); printf("Enter The Marks Of The Student in six subjects\n"); scanf("%d%d%d%d%d%d",&m1,&m2,&m3,&m4,&m5,&m6); if (m1>100||m2>100||m3>100||m4>100||m5>100||m6>100) { printf("You Have Entered The Worng Values,Please Verify\n"); } if (m1<35||m2<35||m3<35||m4<35||m5<35||m6<35) { printf("The Result Is Fail\n"); } total=m1+m2+m3+m4+m5+m6; avg=(total)/6; if(avg>90&&avg<100) { printf("A Grade\n"); } if (avg>75&&avg<90) { printf("B Grade\n"); } if (avg>55&&avg<75) { printf("C Grade\n"); } if (avg>35&&avg<55) { printf("D Grade\n"); } if (avg<35) { printf("The Result Is Fail\n\n"); } printf("Student Name Is %s\n\n",s); printf("Total Marks Is %d \n\n",total); printf("Avg Is %f \n\n",avg); getch(); } void main() { int h; clrscr(); printf("how many times students marks grading to continue\n\n\n And press '*' to terminates\n\n"); scanf("%d",&h); while(h!='*') { avgcaluclation(); h++; } getch(); }












FINDING DATE BY USING DOS





#include<stdio.h> #include<conio.h> #include<dos.h> main() { struct date d; getdate(&d); printf("Currect Date Of This system is :%d: %d: %d",d.da_day,d.da_mon,d.da_year); getch(); }






CHECKING NUMBER IS EVEN OR ODD






#include<stdio.h> #include<conio.h> main() { int n; clrscr(); printf("Enter the number to check \n"); scanf("%d",&n); if (n%2==0) printf("Given Number Is Even"); else printf("Given Number Is Odd"); getch(); }















PRINTING OF NUMBERS FROM U R CHOICE TO 100






#include<stdio.h> /* this program is use to print the value of u r choice */ #include<conio.h> main() { int n,i=0; clrscr(); printf("Enter the number which is < 100 to print the following values\n"); scanf("%d",&n); if(n<=100) { while(i<=n) { printf("%d\t",i); i++; }} else printf("The value is larger than 100"); getch(); return 0; }













PRINTING OF NUMBERS FROM U R CHOICE TO  500









#include<stdio.h> #include<conio.h> void main() /* This Program Is used to print the following numbers from given number*/ { long int i,n; clrscr(); printf("Enter the value for print following numbers to range of 500 is \n"); scanf("%ld",&n); if(n<=500) { for(i=n;i<500;++n) { i=n; printf("%ld\t",i); }} else printf("this value is larger than 500"); getch(); }















SUM OF EVEN NUMBERS








#include<stdio.h> #include<conio.h> /* this prog is used to perfom sum of even number by which the given extant*/ main() { long int h,n,a=0; clrscr(); printf("Enter any value to print sum of even number to which given extent \n"); scanf("%ld",&n); for(h=0;h<=n;h++) a=h+a; printf("The value is %d \n",a); getch(); }















SUM OF NATURAL NUMBERS






#include<stdio.h> /* PROGRAM FOR SUM OF NATURAL NUMBERS*/ #include<conio.h> void main() { long int n,i,h=0; clrscr(); printf("Enter the value to print sum of n natural numbers\n"); scanf("%ld",&n); for (i=0;i<=n;i++) h+=i; printf("%ld",h); getch(); }










USING FUNCTION ADDITION - 1










#include<stdio.h> #include<conio.h> int s,x,y,a,b; /* USING FUNCTION ADDITION - 1*/ sum(int a,int b); main() { clrscr(); printf("\tAny two value to know its addition\n"); scanf("%d%d",&x,&y); sum(x,y); printf("\n\n\tSum=%d",s); getch(); } sum(int a,int b) { s=a+b; return(s); }











FUNCTION ADDITION - 2








#include<stdio.h> #include<conio.h> int s,m,n; void s(int m,int n); /* FUNCTION ADDITION -2*/ void main() { clrscr(); printf("enter any two values to add by using functions\n"); scanf("%d%d",&m,&n); s(m,n); getch(); } void s(int m,int n) { s=m+n; printf("\n\nAfter the addition the two values sum is::%d\n",s); }











FUNCTION ADDITION - 3






#include<stdio.h> #include<conio.h> /*Function ADDITION - 3*/ int s,m,n; int sum(int m,int n); void main() { clrscr(); printf("enter any two values to add by using functions\n"); scanf("%d%d",&m,&n); sum(m,n); getch(); } int sum(int m,int n) { s=m+n; printf("\n\n sum is::%d\n",s); }







FUNCTION OF ADDING  ARRAY ELEMENTS :

Function with Aurguments and Return Values







#include<stdio.h> #include<conio.h> int add(int [],int); /*function with argument and return value */ main() { int i,a[40],n,s; clrscr(); printf("Enter the size of array\n"); scanf("%d",&n); printf("Now enter the %d of elements:\n",n); for(i=0;i<n;i++) scanf("%d",&a[i]); s=add(a,n); printf("Sum of total array is: %d\n",s); getch(); } int add(int a[],int n) { int s=0,i; for(i=0;i<n;i++) s+=a[i]; return(s); }












USING FUNCTION MATRIX ARRANGEMENT :






#include<stdio.h> #include<conio.h> print(int x[20][20],int p,int q); void main() { int i,j,x[20][20],p,q; clrscr(); printf("Enter the size of row and coloum of matrix\n"); scanf("%d%d",&p,&q); printf("Now enter %d by %d elements\n",p,q); for(i=0;i<p;i++) for(j=0;j<q;j++) scanf("%d",&x[i][j]); print(x,p,q); printf("\n\nThank you\n"); getch(); } print(int x[20][20],int p,int q) { int i,j; for(i=0;i<p;i++) { for(j=0;j<q;j++) printf("%d\t",x[i][j]); printf("\n"); } }













FUNCTION WITH ARGUMENTS AND RETURN VALUE OF MATRIX ARRANGEMENT






#include<stdio.h> #include<conio.h> int add(int [],int); /*function with argument and return value */ main() { int i,a[40],n,s; clrscr(); printf("Enter the size of array\n"); scanf("%d",&n); printf("Now enter the %d of elements to add all : \n",n); for(i=0;i<n;i++) scanf("%d",&a[i]); s=add(a,n); printf("Sum of total array elementsis: %d\n",s); getch(); } int add(int a[],int n) { int s=0,i; for(i=0;i<n;i++) s+=a[i]; return(s); }














GENETATING FIBNOCI SEREIES






#include<stdio.h> /* to generate fibnoci sreies*/ #include<conio.h> /* by using function recursion on second"fibno" function*/ int fibonacci(int); main() { int n,i; clrscr(); printf("Enter no. of elements to print fibnociseries\n"); scanf("%d",&n); for(i=1;i<=n;i++) printf("%d\t",fibonacci(i)); getch(); } int fibonacci(int n) { int fno; if (n==1) return 1; else if (n==2) return 1; else fno=fibonacci(n-1)+fibonacci(n-2); return fno; }
















GENERATE FACTORIAL SERIES





#include<stdio.h> #include<conio.h> /* to genetate factorial series*/ int fact(int); main() { int n,result; clrscr(); printf("Enter the number to find factorial\n"); scanf("%d",&n); result= fact(n); printf("The factorial of %d is := %d\n",n,result); getch(); } int fact(int n) { int f; if (n==0) return 1; else f=n*fact(n-1); return f; }


















FUNCTION WITH NO AURGUMENT AND NO RETURN VALUES






#include<stdio.h> #include<conio.h> void dis(int a[],int); /* function with no arguments and no return values*/ void main() { int i,n,x[40]; clrscr(); printf("Enter the size of an array\n"); scanf("%d",&n); printf("Enter the elements of given size of array\n"); for(i=0;i<n;i++) scanf("%d",&x[i]); dis(x,n); getch(); } void dis(int a[],int s) { int i; printf("Entered elements is :\t"); for(i=0;i<s;i++) printf("%d\t",a[i]); }















FUNCTION WITH AURGUMENT AND

 NO  RETUNT VALUE








#include<stdio.h> #include<conio.h> int n,m,t; /* funtion with aurgments and no return values*/ void swp(int m,int n) { printf("Entered value before swaping is a=%d\tb=%d \n\n",m,n); t=m;m=n;n=t; printf("Entered values After swaping is a=%d\tb=%d",m,n); } main () { clrscr(); printf("Enter a and b value to swap by using functions\n"); scanf("%d%d",&m,&n); swp(m,n); getch(); }
















FINDING OF LARGEST OF THREE







/* A progrem to find largest by using "" only IF ""*/ #include<stdio.h> #include<conio.h> main() { int x,y,z,max; clrscr(); printf("Enter the three numbers to find which is great\n"); scanf("%d%d%d",&x,&y,&z); /* to finding the maximum begins*/ max=x; if (y>max) max=y; if (z>max) max=z; /*to finding the maximum ends by only if*/ printf("The maximum of three numbers is %d",max); getch(); }
















PALLENDROME  CHECKING OF GIVEN NUMBER









#include<stdio.h> #include<math.h> void main() { long int n, num, rev = 0, dig; clrscr(); printf("\n\n\t ENTER A NUMBER...: "); scanf("%ld", &num); n = num; while(num>0) { dig = num % 10; rev = rev * 10 + dig; num = num / 10; } if (n == rev) printf("\n\t GIVEN NUMBER IS A PALINDROME"); else printf("\n\t GIVEN NUMBER NOT A PALINDROME"); getch(); }


















USING SWITCH CASE BY ARTHEMATIC OPERATION







#include<stdio.h> /* USING SWITCH CASE ARTHEMATIC PROGRAMES*/ #include<conio.h> int choice,like; main() { float a,b,c,d; clrscr(); printf("main menu\n"); printf("press 1.ADDITION\n"); printf("press 2.SUBTRACTION\n"); printf("press 3.MULTIPLICATION\n"); printf("press 4.DIVISION\n"); printf("Enter your choice to perform....\n"); scanf("%d",&choice); if (choice==1) { printf("press 1.ADDITION With Two digits\n"); printf("press 2.ADDITION With Three digits\n"); printf("Enter your like......."); scanf("%d",&like); if (like==1||like==1) { printf("enter the values of a and b\n"); scanf("%f%f",&a,&b); c=a+b; printf("The sum of a+b is %f",c); } else if(like==2||like==2) { printf("enter the values of a,b and c\n"); scanf("%f%f%f",&a,&b,&c); d=a+b+c; printf("the sume of a+b+c is %f",d); } else printf("Wrong Choice"); } else if (choice==2) { printf("press 1.SUBTRACTION With Two digits\n"); printf("press 2.SUBTRACTION With Three digits\n"); printf("enter your like___"); scanf("%d",&like); if (like==1||like==1) { printf("Enter the values of a and b\n"); scanf("%f%f",&a,&b); c=a-b; printf("the value of a-b is %f",c); } else if(like==2||like==2) { printf("Enter the values of a,b and c\n"); scanf("%f%f%f",&a,&b,&c); d=a-b-c; printf("the value of a-b-c is %f",d); } else printf("Wrong Choice"); } else if (choice==3) { printf("press 1.MULTIPLICATION With Two digits\n"); printf("press 2.MULTIPLICATION With Three digits\n"); printf("enter your like___ "); scanf("%d",&like); if (like==1||like==1) { printf("Enter the values of a,b\n"); scanf("%f%f",&a,&b); c=a*b; printf("the result of a*b is %f",c); } else if (like==2||like==2) { printf("Enter the values a,b and c"); scanf("%f%f%f",&a,&b,&c); d=a*b*c; printf("the result of a*b*c is %f",d); } else printf("Wrong Choice"); } else if (choice==4) { printf("press 1.DIVISION With Two digits\n"); printf("press 2.DIVISION With Three digits\n"); printf("enter your like___"); scanf("%d",&like); if (like==1||like==1) { printf("Enter the values of a/b \n"); scanf("%f%f",&a,&b); c=a/b; printf("The value of a/b is %f",c); } else if (like==2||like==2) { printf("Enter the values of (a/b)/c"); scanf("%f%f%f",&a,&b,&c); d=(a/b)/c; printf("The value of (a/b)c is %f",d); } else printf("Wrong Choice"); } else printf("Wrong Choice"); getch(); }




















PRINTING NAME :






#include<stdio.h> #include<conio.h> main() { clrscr(); printf("harish the ADMINSTRATOR"); getch(); }














PRINTING PATTERN - 1





#include<stdio.h> /****************************/ #include<conio.h> /* h */ #include<string.h> /* ha */ main() /* har */ { /* hari */ char s[500]; /* haris */ int len,i,j; /* harish */ clrscr(); printf("Enter any string to print it in an pattern\n\n"); gets(s); len=strlen(s); for(i=0;i<len;i++) { for(j=0;j<=i;j++) printf("%c",s[j]); printf("\n"); } getch(); }













PRINTING PATTERN - 3





#include<stdio.h> /**********************/ #include<conio.h> /* * */ main() /* * * * */ { /* * * * * * */ int row,col,n,temp; /* * * * * * * * */ clrscr(); printf("how many rows of pyramid pattern of *'s to print\n"); scanf("%d",&n); temp=n; for(row=1;row<=n;row++) { for(col=1;col<temp;col++) printf(" "); temp--; for(col=1;col<=2*row-1;col++) printf("*"); printf("\n"); } getch(); }

















PRINTING ALPHABATES









#include<stdio.h> #include<conio.h> main() { char ch='A'; int n,i,j,sp=0; clrscr(); printf("how many rows of''alphabates ''to print\n"); scanf("%d",&n); for(i=n;i>=1;i--) { for(j=1;j<=sp;j++) printf(" "); sp++; for(j=1;j<=i;j++) { printf("%c ",ch); ch++; } printf("\n"); ch='A'; } getch(); }


















PRINTING PROFIT OR LOSS ABOUT THE PRODUCT YOU BUYED








#include<stdio.h> #include<conio.h> main() { long int x,y,z; float pft,los; char h[20]; clrscr(); printf("Enter the details whether you get loss or profit\n"); printf("Enter the name of the object that you purchased\n"); scanf("%s",&h); printf("Enter the price of a object that you buyed\n"); scanf("%ld",&x); printf("Now Enter the price which you sell the object\n"); scanf("%ld",&y); z=y-x; if (z>=0) { printf("After selling you got profit of purchasing that %s\n",h); printf("the profit is %ld\n",z); pft=(y-x)/100; printf("The persentage of profit is %f\n",pft); } else if (z<=0) { z=x-y; printf("After selling you got loss of purchasing that %s\n",h); printf("the loss is %ld \n",z); los=(x-y)/100; printf("The persentage of loss is %f\n",los); } else { printf("No Profit No Gain just time waste of purchasing that %s\n",h); } printf("Thank u for checking"); getch(); }















  PALLENDROM  CHECKING





#include<stdio.h> #include<conio.h> main() { long int n,num,rev=0,dig; clrscr(); printf("Enter the value to find reverse and check it is palandrom or not \n"); scanf("%ld",&num); n=num; while(num>0) { dig=num%10; rev=rev*10+dig; /*to check given number is palendrium or not*/ num=num/10; } if (n==rev) printf("Given number is palandrium"); else printf("Given number is not a palandrium"); getch(); }
















POINTER USEING  PROGRAMME




#include<stdio.h> #include<conio.h> main() { int a=77,*p1,**p2; clrscr(); p1=&a; p2=&p1; printf("A=%d\n\n",a); printf("A=%d\n\n",*p1); printf("A=%d\n\n",**p2); getch(); }


















SUM OF DIFFERENT TYPES OF PROGRAMMES






#include<stdio.h> #include<conio.h> main() { int a,n,h; clrscr(); printf("main menu\n"); printf("press 1.sum of n integers\n"); printf("press 2.sum of n even integers\n"); printf("press 3.sum of n odd integers\n"); printf("press 4.sum of n square integers\n"); printf("select your choiceis____\t"); scanf("%d",&h); if (h>=5) { printf("you have entered wrong values"); } else { printf("Enter the values of n to perform above task is\n"); scanf("%d",&n); switch(h) { case 1:printf("sum of n integers\n"); a=(n*(n+1))/2; break; case 2:printf("sum of n even integers\n"); a=n*(n+1); break; case 3:printf("sum of n odd integers\n"); a=n*n; break; case 4:printf("sum of n square integets\n"); a=(n*(n+1)*(2*n+1))/6; break; } printf("the result is %d \n",a); } getch(); }

















SORTING  NAMES  BY  ALPHABATES ORDER






#include<stdio.h> #include<conio.h> #include<string.h> main() { int i,n,j; char s[30][30],t[30]; clrscr(); for(i=0;i<80;i++) printf("*"); printf("\n\nProgram to print entered names in assending order\n\n"); printf("How many names u want to enter \n\n"); scanf("%d",&n); fflush(stdin); for(i=0;i<n;i++) { printf("Enter %d name:\n",i+1); gets(s[i]); } printf("Names before sorted is:\n________________________________________________\n\n"); for(i=0;i<n;i++) puts(s[i]); printf("Names after Entered is:\n_________________________________________________\n\n"); for(i=0;i<n-1;i++) for(j=i+1;j<n;j++) if (strcmp(s[i],s[j])>0) { strcpy(t,s[i]); strcpy(s[i],s[j]); strcpy(s[j],t); } for(i=0;i<n;i++) printf("%s\n",s[i]); getch(); }




















COUNTING WORDS,SPACES,LETTERS,LINES






#include<stdio.h> #include<conio.h> #include<string.h> main() { int lns=0,wrd=0,alp=0,i=0; char s[80]; clrscr(); printf("Enter any sentence to count and '*' to terminate:\n"); scanf("%[^*]",s); while(s[i]!='\0') { if ((s[i]>='A'&&s[i]<='Z')||(s[i]>='a'&&s[i]<='z')) alp++; if ((s[i]==' ')||(s[i]=='\n')) wrd++; if (s[i]=='\n') lns++; i++; } printf("The total count of strings in \n %s is :\n\n\n",s); printf("Charecters: %d\n",i); printf("Alphabates: %d\n",alp); printf("Words : %d\n",wrd); printf("Lines : %d\n",lns); getch(); }

















COLOURING  STRING





#include<stdio.h> #include<conio.h> main() { char s[80]; clrscr(); printf("Enter any string or line to print as it is\n"); gets(s); textcolor(BLACK); textbackground(WHITE); cputs(s); getch(); }

























FUNTION OF STRUCTURE USING A STUDENTS




#include<stdio.h> #include<conio.h> #include<string.h> main() { struct date { int d; int m; int y; }; struct student { int rollno; char name[20]; int marks[6]; int sum; float per; struct date dab; }; struct student x[100]; int i,j,n; clrscr(); printf("Enter the number of students program\n"); scanf("%d",&n); for(i=0;i<25;i++) printf("__"); for(i=0;i<n;i++) { printf("\n\nEnter the roll no,name of student and date of birth(day,month,year)of :-%d\n",i+1); scanf("%d%s%d%d%d",&x[i].rollno,x[i].name,&x[i].dab.d,&x[i].dab.m,&x[i].dab.y); printf("enter the marks in 6 subjects of %s\n",x[i].name); for(j=1;j<=6;j++) scanf("%d",&x[i].marks[j]); } /* finding total andpersentage*/ for(i=0;i<n;i++) { x[i].sum=0; for(j=1;j<6;j++) x[i].sum+=x[i].marks[j]; x[i].per=(float)x[i].sum/6; } /* printing the values*/ printf("\nRollno\t\tName \t\tpercentage \tdate of birth\n"); for(i=0;i<n;i++) printf("%3d%18s\t\t%9.2f\t%d/%d/%d\n",x[i].rollno,x[i].name,x[i].per,x[i].dab.d,x[i].dab.m,x[i].dab.y); getch(); }



















SWAPING  OF  TWO  NUMBERS





#include<stdio.h> #include<conio.h> main() { int x,y,h; clrscr(); printf("Enter the values of x and y to swap\n"); scanf("%d%d",&x,&y); h=x; x=y; y=h; printf("the values after swaping is x=%d and y=%d",x,y); getch(); }






















SWITHING CONDITION - 2








#include<stdio.h> #include<conio.h> int h,like,a,b,c,d; main() { clrscr(); printf("main menu\n"); printf("1.ADDITION\n"); printf("2.SUBTRACTION\n"); printf("3.MULTIPLICATION\n"); printf("4.DIVISION\n"); printf("Enter your choice to perform....\n"); scanf("%d",&h); switch(h) { case 1: printf("press 1.ADDITION With Two digits\n"); printf("press 2.ADDITION With Three digits\n"); printf("Enter your like....\n"); scanf("%d",&like); if (like==1) { printf("enter the values of a and b\n"); scanf("%d%d",&a,&b); c=a+b; printf("The sum of a+b is %d",c); break; } else if(like==2) { printf("enter the values of a,b and c\n"); scanf("%d%d%d",&a,&b,&c); d=a+b+c; printf("the sume of a+b+c is %d",d); break; } else printf("Wrong value");break; case 2: printf("press 1.SUBTRACTION With Two digits\n"); printf("press 2.SUBTRACTION With Three digits\n"); printf("enter your like___\n"); scanf("%d",&like); if (like==1) { printf("Enter the values of a and b\n"); scanf("%d%d",&a,&b); c=a-b; printf("the value of a-b is %d",c);break; } else if (like==2) { printf("Enter the values of a,b and c\n"); scanf("%d%d%d",&a,&b,&c); d=a-b-c; printf("the value of a-b-c is %d",d); break; } else printf("Wrong value, please veryfy"); break; case 3: printf("press 1.MULTIPLICATION With Two digits\n"); printf("press 2.MULTIPLICATION With Three digits\n"); printf("enter your like___\n"); scanf("%d",&like); if (like==1) { printf("Enter the values of a,b\n"); scanf("%d%d",&a,&b); c=a*b; printf("the result of a*b is %d",c);break; } else if (like==2) { printf("Enter the values a,b and c"); scanf("%d%d%d",&a,&b,&c); d=a*b*c; printf("the result of a*b*c is %d",d); break; } else printf("Wrong value, please veryfy"); break; case 4: printf("press 1.DIVISION With Two digits\n"); printf("press 2.DIVISION With Three digits\n"); printf("enter your like___\n"); scanf("%d",&like); if (like==1) { printf("Enter the values of a/b \n"); scanf("%d%d",&a,&b); c=a/b; printf("The value of a/b is %d",c);break; } else if (like==2) { printf("Enter the values of (a/b)/c"); scanf("%d%d%d",&a,&b,&c); d=(a/b)/c; printf("The value of (a/b)c is %d",d); break; } else printf("Wrong value ,please veryfy"); break; default: printf("Wrong Choice"); break; } getch(); }























SWITHING CONDITION - 3






#include<stdio.h> #include<conio.h> /*this programe perform by u r choosen process*/ main() { int a,b,c,d,h,s; char j; clrscr(); printf("Press 1.Program with two Integers\n press 2.Programe with three Integers \n"); scanf("%d",&h); if (h==1) { printf("Enter Any Two Values"); scanf("%d%d",&a,&b); printf("Main menu \n press 1.ADDITION \n press 2.SUBTRACTION \n press 3.MULTIPLICATION \n press 4.DIVVISION \n press 5.REMINDER\n"); scanf("%d",&j); switch(j) { case 1: c=a+b; break; case 2: c=a-b; break; case 3: c=a*b; break; case 4: c=a/b; break; case 5: c=a%b; break; default: printf("Wrong choice"); break; } printf("The Result Is %d",c); } else if (h==2) { printf("Now Enter three Values to perform program\n"); scanf("%d%d%d",&a,&b,&c); printf("Mainmenu\n press 1.ADDITION\n press 2.SUBTRACTION\n press 3.MULTIPLICATION\n press 4.DIVISION\n press 5.REMAINDER\n"); scanf("%d",&j); switch(j) { case 1: d=a+b+c; break; case 2: d=a-b-c; break; case 3: d=a*b*c; break; case 4: d=a/b/c; break; case 5: d=a%b%c; break; default : printf("Wrong Value"); } printf("The Result Is %d",d); } else printf("Wrong Choice"); getch(); }





















USING POINTER SWAPING




#include<stdio.h> #include<conio.h> int swap(int *,int *); main() { int a,b; clrscr(); printf("Enter any two numbers to swap them by using pointer\n\n"); scanf("%d%d",&a,&b); printf("Before Swaping the Values of a=%d \t b=%d\n\n",a,b); swap(&a,&b); printf("\n\nAfter swaping the values of a=%d \t b=%d",a,b); getch(); } int swap(int *pa,int *pb) { int temp; temp=*pa; *pa=*pb; *pb=temp; }


























TOP BORDER OF AN PAGE BY USING  STARS






#include<stdio.h> main() { int i,j; clrscr(); for(i=0;i<10;i++) { for(j=i;j<10;j++) { printf("*"); printf("\n"); } printf("\t"); } getch(); }



















TO PRINT THE NAME OF A WEEK BY NUMBER






#include<stdio.h> #include<conio.h> main() { int n; clrscr(); printf("enter the number of a day in week of 1 to 7:\n"); scanf("%d",&n); switch(n) { case 1:printf("that is sunday\n");break; case 2:printf("that is monday\n");break; case 3:printf("that is tuesday\n");break; case 4:printf("that is wednesday\n");break; case 5:printf("that is thursday\n");break; case 6:printf("that is friday\n");break; case 7:printf("that is sunday\n");break; default :printf("wrongvalue please verify!!!"); } getch(); }

















STRING WORD REPLACING






#include<stdio.h> #include<conio.h> #include<string.h> main() { char mnstr[80],fdstr[30],rpstr[30]; int i,j,k,r,l,a,pos,lnmn,lnfd,lnrp,move; clrscr(); printf("Enter any string or a sentence\n"); gets(mnstr); printf("Enter any word to select in above sentence\n"); gets(fdstr); printf("Enter the word u want 2 replace\n"); gets(rpstr); lnmn=strlen(mnstr); lnfd=strlen(fdstr); lnrp=strlen(rpstr); for(a=0;a<lnmn;a++) { for(i=a;i<lnmn;i++) { if(mnstr[i]==fdstr[0]) { pos=i; j=0; while(mnstr[i]==fdstr[j]&&mnstr[i]!='\0') { j++; i++; } /* found the position*/ if(j>=lnfd) { move=lnfd-lnrp; /* moving the charecter 2 left*/ if(move>0) { k=i; while(k<=lnmn) { mnstr[k-move]=mnstr[k]; k++; } } else if(move<0) /* moving charecter 2 right */ { k=lnmn; while(k>=i) { mnstr[k-move]=mnstr[k]; k--; } } lnmn-=move; for(r=pos,l=0;l<lnrp;r++,l++) mnstr[r]=rpstr[l]; i=pos+lnrp; } } } } printf("The replaced word sentence is :\n%s",mnstr); getch(); }















No comments: