C Program to find factorial of a numberSimple C Programint main() {int n,i,f=1;printf("enter any num \n");scanf("%d",&n);for(i=1;i
ITS EASY...TRY THIS OUT..TRAPEZOIDAL METHOD#include#include#includefloat valcal(float x){return (x*x*x);}int main(){float a,b,h,c,I;int n,i;printf("THE TRAPEZOIDAL RULE:\n");printf("---------------------");printf("\n\n\nEnter the two limits and the no. of divisions:\n");scanf("%f %f %d",&a, &b, &n);h=(b-a)/n;//printf("\nVALUE of h: %f\n", h);c=a;I=valcal(a)+valcal(b);//printf("\nVALUE FOR a: %f\n", valcal(a));//printf("\nVALUE FOR b: %f\n", valcal(b));for(i=1;i=b){printf("\n\nc>b\n\n");break;}//printf("\nVALUE FOR %f: is %f\n",c, valcal(c));I=I+(2*valcal(c));//printf("\nI right now is %f", I);}printf("\n\n\nThe integration of x*x*x is: %f",(h*I)/2);printf("\n\n\n");system("pause");}SIMPSON'S 1/3RD METHOD#include#include#includefloat valcal(float x){return (1/(1+x*x));}int main(){float a,b,h,c,I;int n,i;printf("THE SIMPSON'S ONE-THIRD RULE:\n");printf("------------------------------");printf("\n\n\nEnter the two limits and the no. of divisions:\n");scanf("%f %f %d",&a, &b, &n);h=(b-a)/n;//printf("\nVALUE of h: %f\n", h);c=a;I=valcal(a)+valcal(b);//printf("\nVALUE FOR a: %f\n", valcal(a));//printf("\nVALUE FOR b: %f\n", valcal(b));for(i=1;ib){printf("\n\nc>b\n\n");break;}//printf("\nVALUE FOR %f: is %f\n",c, valcal(c));if(i%2==0)I=I+(2*valcal(c));elseI=I+4*valcal(c);//printf("\nI right now is %f", I);}printf("\n\n\nThe integration of x*x*x is: %f",(h*I)/3);printf("\n\n\n");system("pause");}NEED MORE HELP...MAIL ME YOUR PROB... SEE YA
#include<stdio.h> #include<conio.h> int main(void) { float a,b,c=0, d=0, e=0,f=0; printf("Please enter two numbers:\n"); scanf("%f %f", &a, &b); c=a+b; d=a-b; e=a*b; f=a/b; printf("The sum of %f and %f is :%f\n", a,b,c); printf("The subtraction of %f and %f is :%f\n", a,b,d); printf("The multiplication of %f and %f is :%f\n", a,b,e); printf("The division of %f by %f is :%f\n",a,b,f); getch(); }
#include#includeint a,f,n,sum=0; printf("Enter any number"); scanf("%d",&n); f=1; for(a=1;a<=n;a ); { f=f*a; } for(f=1;f<=n;f ); { sum=sum f; } printf("sumation of factorial numbers :",sum); getch(); }
#include<stdio.h> #include<conio.h> voidmain() { char n[10] ,total; float a,b,c,d,e,average; printf("enter marks of five subject"); scanf("%f%f%f%f%f",&a,&b,&c,&d,&e); if(a>35&&b>35&&c>35&&d>35&&e>35) printf("congratulation you have passed"); average=total%5 if(average>75) printf(" %f is distictiona",average); else if(average>60) printf("%f=first devision",average); else if(averagea>45) printf("%f=second devision",average); else printf("third devisiona"); getcha(); }
formatted
C Program to find factorial of a numberSimple C Programint main() {int n,i,f=1;printf("enter any num \n");scanf("%d",&n);for(i=1;i
ITS EASY...TRY THIS OUT..TRAPEZOIDAL METHOD#include#include#includefloat valcal(float x){return (x*x*x);}int main(){float a,b,h,c,I;int n,i;printf("THE TRAPEZOIDAL RULE:\n");printf("---------------------");printf("\n\n\nEnter the two limits and the no. of divisions:\n");scanf("%f %f %d",&a, &b, &n);h=(b-a)/n;//printf("\nVALUE of h: %f\n", h);c=a;I=valcal(a)+valcal(b);//printf("\nVALUE FOR a: %f\n", valcal(a));//printf("\nVALUE FOR b: %f\n", valcal(b));for(i=1;i=b){printf("\n\nc>b\n\n");break;}//printf("\nVALUE FOR %f: is %f\n",c, valcal(c));I=I+(2*valcal(c));//printf("\nI right now is %f", I);}printf("\n\n\nThe integration of x*x*x is: %f",(h*I)/2);printf("\n\n\n");system("pause");}SIMPSON'S 1/3RD METHOD#include#include#includefloat valcal(float x){return (1/(1+x*x));}int main(){float a,b,h,c,I;int n,i;printf("THE SIMPSON'S ONE-THIRD RULE:\n");printf("------------------------------");printf("\n\n\nEnter the two limits and the no. of divisions:\n");scanf("%f %f %d",&a, &b, &n);h=(b-a)/n;//printf("\nVALUE of h: %f\n", h);c=a;I=valcal(a)+valcal(b);//printf("\nVALUE FOR a: %f\n", valcal(a));//printf("\nVALUE FOR b: %f\n", valcal(b));for(i=1;ib){printf("\n\nc>b\n\n");break;}//printf("\nVALUE FOR %f: is %f\n",c, valcal(c));if(i%2==0)I=I+(2*valcal(c));elseI=I+4*valcal(c);//printf("\nI right now is %f", I);}printf("\n\n\nThe integration of x*x*x is: %f",(h*I)/3);printf("\n\n\n");system("pause");}NEED MORE HELP...MAIL ME YOUR PROB... SEE YA
%f is used as a format mask to represent a floating point number.Any of the "formatted" io functions can use this: printf, fprintf, scanf, etc.Example:float n = 1.5;printf("%f", n); // prints the value of n
#include<stdio.h> void main() { float a=20,b=5,c=0; c=(a+b)/2; printf("%f",c); getch() }
#include<stdio.h> #include<conio.h> int main(void) { float a,b,c=0, d=0, e=0,f=0; printf("Please enter two numbers:\n"); scanf("%f %f", &a, &b); c=a+b; d=a-b; e=a*b; f=a/b; printf("The sum of %f and %f is :%f\n", a,b,c); printf("The subtraction of %f and %f is :%f\n", a,b,d); printf("The multiplication of %f and %f is :%f\n", a,b,e); printf("The division of %f by %f is :%f\n",a,b,f); getch(); }
#include#includeint a,f,n,sum=0; printf("Enter any number"); scanf("%d",&n); f=1; for(a=1;a<=n;a ); { f=f*a; } for(f=1;f<=n;f ); { sum=sum f; } printf("sumation of factorial numbers :",sum); getch(); }
void main() { int i; float n1,n2; abc: printf("Enter two nos "); scanf("%f%f",&n1,&n2); printf("\n %f + %f = %f " ,n1,n2,n1+n2); printf("\n %f - %f = %f " ,n1,n2,n1-n2); printf("\n %f x %f = %f " ,n1,n2,n1*n2); printf("\n %f / %f = %f " ,n1,n2,n1/n2); printf("\npress 5 to make another calculation"); scanf("%d",&i); if (i==5) goto abc; }
#include<stdio.h> #include<math.h> main() { float A,a,b,c,s; printf("entr the value of a,b and c"); scanf("%f %f %f",&a,&b,&c); A=sqrt(s*s-a*s-b*s-c) printf("area of the triangle %f\n"A); getch(); }
#include<stdio.h> #include<conio.h> voidmain() { char n[10] ,total; float a,b,c,d,e,average; printf("enter marks of five subject"); scanf("%f%f%f%f%f",&a,&b,&c,&d,&e); if(a>35&&b>35&&c>35&&d>35&&e>35) printf("congratulation you have passed"); average=total%5 if(average>75) printf(" %f is distictiona",average); else if(average>60) printf("%f=first devision",average); else if(averagea>45) printf("%f=second devision",average); else printf("third devisiona"); getcha(); }
#include<stdio.h> #include<conio.h> void main() { float a,b,c,z,d,x,y; clrscr(); printf("Enter the value of a,b,c"); scanf("%f %f %f",&a,&b,&c); d=((b*b)-(4*a*c)); z=sqrt(d); x=(-b+z)/(2*a); y=(-b+z)/(2*a); printf("The Quadratic equation is x=%f and y=%f",x,y); getch(); } This answer does not think about imaginary roots. I am a beginner in C programming. There might be flaws in my code. But, it does well. the code is #include<stdio.h> #include<math.h> main() { float a, b, c; float dis, sqdis, real, imag, root1, root2; printf("This program calculates two roots of quadratic equation of the form ax2+bx+c=0.\n"); printf("\n"); printf(" please type the coefficients a, b and c\n"); printf("\n"); printf("a = "); scanf("%f", &a); printf("\n"); printf("b = "); scanf("%f", &b); printf("\n"); printf("c = "); scanf("%f", &c); printf("\n"); dis = (b*b-4*a*c); if(dis < 0) { sqdis = sqrt(-dis); real = -b/(2*a); imag = sqdis/(2*a); printf(" The roots of the quadratic equations are \n x1\t=\t %f + %f i\n x2\t=\t %f - %f i\n", real, imag, real, imag); } else { sqdis = sqrt(dis); root1 = -b/(2*a)+sqdis/(2*a); root2 = -b/(2*a)-sqdis/(2*a); printf("The two roots of the quadratic equations are %f and %f.\n", root1, root2); } system("pause"); }
#include#includevoid main(){int a,b,c;float avrg;printf("enter the first number:");scanf("%d",&a);printf("enter the second number:");scanf("%d",&b);printf("enter the third number:");scanf("%d",&c);avrg=(a+b+c)/3.0;printf("The average of given numbers is:%f",&f);getch();}this c program is specifically for three variables only.