Posts

Python program to check prime numbers

 # Check if a number is prime num = int(input("Enter a number: ")) if num > 1:     for i in range(2, int(num ** 0.5) + 1):         if num % i == 0:             print(f"{num} is not a prime number")             break     else:         print(f"{num} is a prime number") else:     print(f"{num} is not a prime number")

Python program to check armstrong number

 # Check if a number is an Armstrong number num = int(input("Enter a number: ")) order = len(str(num)) sum = 0 temp = num while temp > 0:     digit = temp % 10     sum += digit ** order     temp //= 10 if num == sum:     print(f"{num} is an Armstrong number") else:     print(f"{num} is not an Armstrong number")

Python program to calculate compund interest

 # Calculate simple interest principal = float(input("Enter principal amount: ")) rate = float(input("Enter rate of interest: ")) time = float(input("Enter time (in years): ")) si = (principal * rate * time) / 100 print(f"Simple Interest: {si}")

Python program to calculate simple interest

 # Calculate simple interest principal = float(input("Enter principal amount: ")) rate = float(input("Enter rate of interest: ")) time = float(input("Enter time (in years): ")) si = (principal * rate * time) / 100 print(f"Simple Interest: {si}")

Python program for finding factorial

 # Find factorial of a number num = int(input("Enter a number: ")) factorial = 1 for i in range(1, num + 1):     factorial *= i print(f"Factorial of {num}: {factorial}")

Python program to add to numbers

 # Program to add two numbers entered by the user # Take input from the user num1 = input("Enter the first number: ") num2 = input("Enter the second number: ") # Convert inputs to float (to support decimals) sum = float(num1) + float(num2) # Display the result print("The sum of {0} and {1} is {2}".format(num1, num2, sum))

c program of gauss ELIMINITION method

/*Gauss Elimination */ # include <stdio.h> # include <conio.h> # include <math.h> # define MAX 10 void main() { int i,j,n,k; float mat[MAX][MAX],x[MAX],temp,pivot,sum=0; clrscr(); printf("\t\t\t GAUSS ELIMINITION METHOD\n"); printf("-------------------------------------------------------------------\n"); printf("Enter No of Equtions : "); scanf("%d",&n); printf("Enter Coefficients of Eqution \n"); for(i=1;i<=n;i++) for(j=1;j<=n;j++) scanf("%f",&mat[i][j]); printf("Enter Constant value\n"); for(i=1;i<=n;i++) { scanf("%f",&mat[i][n+1]); x[i]=mat[i][n+1]; } for(i=2;i<=n;i++) { for(j=i;j<=n;j++) { pivot=mat[j][i-1]/mat[i-1][i-1]; for(k=i-1;k<=n+1;k++) mat[j][k]=mat[j][k]-pivot*mat[i-1][k]; } } printf("Eliminated matrix as :- \n"); for(i=1;i<=n;i++) { for(j=1;j<=n+1;j++) printf("\t%.2f",mat[i][j]); p...

facebook page of the blog

click here  to see the facebook page of this blog. click on LIKE................. :)

C Program Of NA Using Trapezoidal Interpolation

/*Trapezoidal rule */ # include <stdio.h> # include <conio.h> # define MAX 20 void main() { int i,j,n; float x[MAX],y[MAX],sum=0,h,res; clrscr(); printf("Solution using Trapezoidal rule \n"); printf("Enter Number of data points : "); scanf("%d",&n); printf("Enter value of table value set by set\n"); for(i=1;i<=n;i++) { printf("Enter value of x[%d] and y[%d] ",i,i); scanf("%f%f",&x[i],&y[i]); } h=x[2]-x[1]; printf("\nInterval :=%f\n",h); sum=y[1]+y[n]; for(i=2;i<n;i++) sum=sum+y[i]*2; res=sum*(h/2); printf ("Integral from %3.2f to %3.2f is : = %f",x[1],x[n],res); getch(); } OUTPUT :- Solution using Trapezoidal rule Enter Number of data points : 6 Enter value of table value set by set Enter value of x[1] and y[1] 7.47 1.93 Enter value of x[2] and y[2] 7.48 1.95 Enter value of x[3] and y[3] 7.49 1.98 Enter value of x[4] and y[4] 7.50 2.01 Ente...

C Program Of NA Using Simpson 1/3 Rule

/*Simpson 1/3 Rule */ # include <stdio.h> # include <conio.h> # define MAX 20 void main() { int i,j,n; float x[MAX],y[MAX],sum=0,h,res; clrscr(); printf("Solution of 1/(1+x)dx using Simpson's 1/3 rule \n"); printf("Enter Number of data points : "); scanf("%d",&n); printf("Enter value of table value set by set\n"); for(i=1;i<=n;i++) { scanf("%f",&x[i]); y[i]=1/(x[i]+1); } printf("X \t\t Y\n"); for(i=1;i<=n;i++) printf("%f\t%f\n",x[i],y[i]); h=x[2]-x[1]; printf("\nSegment Interval `h':=0.25\n"); sum=sum+y[1]+y[n]; for(i=2;i<n;i++) { if(i%2==0) sum=sum+y[i]*4; else sum=sum+y[i]*2; } res=sum*(0.25/3); printf ("Integral from %3.2f to %3.2f is : = %f",x[1],x[n],res); getch(); } OUTPUT Solution of 1/(1+x)dx using Simpson's 1/3 rule Enter Number of data points : 5 Enter value of table value for x column 0 .25 .50 .75 1 X Y ...

C Program Of NA Using Simpson 3/8 Rule

/*Simpson 3/8 rule */ # include <stdio.h> # include <conio.h> # define MAX 20 void main() { int j,n=0; float x[MAX],y[MAX],sum=0,h,res,lb,ub,i; clrscr(); printf("Solution of 1/(1+x)dx using Simpson's 3/8 rule \n"); printf ("Enter initial value : "); scanf("%f",&lb); printf("Enter final value : "); scanf("%f",&ub); printf("Enter no. of Subinterval : "); scanf("%f",&h); h=(ub-lb)/h; for(i=lb;i<=ub;i=i+h) { x[n]=i; y[n]=1/(1+x[n]); n++; } printf("No.\t X\t\tY=1/(1+x)\n"); printf("---------------------------------------\n"); sum=y[0]+y[n-1]; for(j=0;j<n;j++) printf("%d\t%f\t%f\n",j,x[j],y[j]); printf("---------------------------------------\n"); for(j=1;j<n-1;j++) { if(j%3==0) sum=sum+y[j]*2; else sum=sum+y[j]*3; } res=((3*h)/8)*sum; printf("\nIntegral from %f to %f when h = %f is = %f",x[0],x[n-1...

C Program Of NA Using Runga-Kutta Mthod Of 4th Order

/* Runge-kutta method of 4th order to solve 10*dy/dx=(x*x)+(y*y)*/ # include <stdio.h> # include <conio.h> void main() { int c=0; float x,y0,xp,h,i,y1,m1,m2,m3,m4; float f(float,float); clrscr(); printf("Solution by Runge kutta 2nd order Method\n"); printf("Enter initial Boundry condition x,y : "); scanf("%f%f",&x,&y0); printf("Enter Value of X at which Y is required : "); scanf("%f",&xp); printf("Enter Interval ,h : "); scanf("%f",&h); printf(" No. X\t m1 \t m2\t m3 \t m4 \t Y\n"); printf("-------------------------------------------------------------------\n"); for(i=x;i<=xp;i=i+h) { c++; m1=h*f(i,y0); m2=h*f(i+(h/2),y0+(m1/2)); m3=h*f(i+(h/2),y0+(m2/2)); m4=h*f(i+h,y0+m3); y1=y0+((m1+2*m2+2*m3+m4)/6); printf("%2d %5.6f %5.6f %5.6f %5.6f %5.6f %5.6f\n",c,i,m1,m2,m3,m4,y1); y0=y1; } getch(); } ...

Program in C to insert a node at the last position in a given doubly linked list.

#include<stdio.h> #include<conio.h> #include<alloc.h> #define null 0 void main() { struct dnode { struct dnode *prev; int data; struct dnode *next; } *temp,*start,*end,*n; int i; char c; clrscr(); start=end=null; for(i=0;i<=1;i++) { if(start==null) { printf("enter data for the node:"); scanf("%d",&temp->data); temp->next=null; temp->prev=null; start=temp; end=temp; } else { while(1) { printf("are you want to add another node(y/Y):"); fflush(stdin); scanf("%c",&c); if(c=='y'||c=='Y') { n=(struct dnode*)malloc(sizeof(struct dnode)); printf("enter data for the node:"); scanf("%d",&n->data); n->next=null; ...

Program in C to insert a node at first position in a given doubly linked list.

#include<stdio.h> #include<conio.h> #include<alloc.h> #define null 0 void main() { struct dnode { struct dnode *prev; int data; struct dnode *next; } *temp,*start,*end,*n; int i; char c; clrscr(); start=end=null; for(i=0;i<=1;i++) { if(start==null) { printf("enter data for the node:"); scanf("%d",&temp->data); temp->next=null; temp->prev=null; start=temp; end=temp; } else { while(1) { printf("are you want to add another node(y/Y):"); fflush(stdin); scanf("%c",&c); if(c=='y'||c=='Y') { n=(struct dnode*)malloc(sizeof(struct dnode)); printf("enter data for the node:"); scanf("%d",&n->data); n->next=null; ...

Program in C to subtract two polynomials.

#include<stdio.h> #include<conio.h> #include<stdlib.h> #define NULL 0 void main() { struct poly { int coff; int expo; struct poly *link; }*temp1,*start1,*temp2,*start2,*start3,*temp3; int n,i,z=1,num; char c; clrscr(); start1=NULL; printf("\tPOLYNOMIAL CREATION IN LINK LIST AND SUBTRACTION\n\n"); while(1) { if(start1==NULL) { temp1=(struct poly*)malloc(sizeof(struct poly)); printf("Enter Coefficient and Exponent for Node %d\n",z); scanf("%d %d",&temp1->coff,&temp1->expo); start1=temp1; temp1->link=NULL; } else { temp1->link=(struct poly*)malloc(sizeof(struct poly)); temp1=temp1->link; printf("Enter Coefficient and exponent for Node %d\n",z); scanf("%d %d",&temp1->coff,&temp1->expo); } z++; printf("Do you want to create another node\n"); fflush(stdin); scanf("%c",&c); if(c!='y') { temp1->link=NULL; break; } } ...

Program in C to add two polynomials.

#include<stdio.h> #include<conio.h> #include<stdlib.h> #define NULL 0 void main() { struct poly { int coff; int expo; struct poly *link; }*temp1,*start1,*temp2,*start2,*start3,*temp3; int n,i,z=1,num; char c; clrscr(); start1=NULL; printf("\tPOLYNOMIAL CREATION IN LINK LIST AND ADDITION\n\n"); while(1) { if(start1==NULL) { temp1=(struct poly*)malloc(sizeof(struct poly)); printf("Enter Coefficient and Exponent for Node %d\n",z); scanf("%d %d",&temp1->coff,&temp1->expo); start1=temp1; temp1->link=NULL; } else { temp1->link=(struct poly*)malloc(sizeof(struct poly)); temp1=temp1->link; printf("Enter Coefficient and exponent for Node %d\n",z); scanf("%d %d",&temp1->coff,&temp1->expo); } z++; printf("Do you want to create another node\n...

program in C to store any polynomial using linked list.

#include<stdio.h> #include<conio.h> #include<stdlib.h> #define NULL 0 void main()  {   struct poly    {     int coff;     int expo;     struct poly *link;    }*temp,*start,*n1,*prev;   int n,i,z=1,num;   char c;   clrscr();   start=NULL;   n1=NULL;   printf("\tPOLYNOMIAL CREATION IN LINK LIST AND TRAVERSAL\n\n");   while(1)    {     if(start==NULL)      {                 temp=(struct poly*)malloc(sizeof(struct poly));                 printf("Enter Coefficient and exponent for Node %d\n",z);                 scanf("%d %d",&temp->coff,&...

idea free caller tune for one month..

dial 54444 from ur idea mobile to get 1 month free caller tune................ njoy..............................

Get all latest updates from google for free

 Now u can get all the information's to get just dial 180041999999(toll free) and say your needs then you will receive an sms relevant to your needs. Eg: if you want meaning for a particular word just call and say the word the relevant meaning will be sent through sms

how to get puk number of airtel

Sim locked? need to unlock it? just type your mobile number and sent to 785 immediately your will receive your PUK code and PIN code directly into your inbox., Enjoy.,!!