Machine Learning

Briefing in Python Machine Learning (ML) is that field of computer science with the help of which the computer systems can provide a sense to data in much the same way as human beings do. It is a type of artificial intelligence that extracts patterns out of raw data by using an algorithm or method.... Continue Reading →

List Length in Python

The length of a list can be calculated in Python by using various methods. The built-in len() method in Python is widely used to calculate the length of any sequential data type. It calculates the number of elements or items in a list and returns the same as the length of the list. l=[2,4,6,8,10] print("The length of... Continue Reading →

Sum of elements of array

#include <iostream> using namespace std; int main (){ int arr[] = {6,12,4,7,9 }; int n = 7, sum = 0; for(int i = 0; i<n ; i++){ sum+=arr[i]; } cout<<"The array sum is "<<sum; return 0; }

Transpose of a matrix in C

#include <stdio.h> int main() { int matrix[10][10], transpose[10][10], row, col, i, j; printf("Enter rows and columns: "); scanf("%d %d", &row, &col); printf("\nEnter matrix elements:\n"); for (i = 0; i < row; ++i) for (j = 0; j < col; ++j) { printf("Enter element a%d%d: ", i + 1, j + 1); scanf("%d", &matrix[i][j]); } printf("\nEntered... Continue Reading →

Matrix Addition in C

#include <stdio.h> int main() { int row, col, mat1[100][100], mat2[100][100], matsum[100][100], i, j; printf("Enter the number of rows: "); scanf("%d", &row); printf("Enter the number of columns"); scanf("%d", &col); printf("\nEnter elements of 1st matrix:\n"); for (i = 0; i < row; ++i) for (j = 0; j < col; ++j) { printf("Element a%d%d: ", i +... Continue Reading →

Hosoya’s Triangle or Fibonacci Triangle in C

The Hosoya's triangle (originally Fibonacci triangle) is a triangular arrangement of numbers as it is shown in pascal triangle based on the Fibonacci series. #include<stdio.h> #include<stdlib.h> int main(){ int a=0,b=1,i,c,n,j; system("cls"); printf("Enter the number of lines you want:"); scanf("%d",&n); for(i=1;i<=n;i++) { a=0; b=1; printf("%d\t",b); for(j=1;j<i;j++) { c=a+b; printf("%d\t",c); a=b; b=c; } printf("\n"); } return 0; }

Triangular Number Pattern in C

#include<stdio.h> #include<stdlib.h> int main(){ int i,j,k,l,n; system("cls"); printf("enter the range="); scanf("%d",&n); for(i=1;i<=n;i++) { for(j=1;j<=n-i;j++) { printf(" "); } for(k=1;k<=i;k++) { printf("%d",k); } for(l=i-1;l>=1;l--) { printf("%d",l); } printf("\n"); } return 0; }

Matrix Multiplication in C

#include <stdio.h> int main() { int m, n, p, q, c, d, k, sum = 0; int first[10][10], second[10][10], multiply[10][10]; printf("Enter number of rows and columns of matrix 1 \n"); scanf("%d%d", &m, &n); printf("Enter elements of first matrix\n"); for (c = 0; c < m; c++) for (d = 0; d < n; d++) scanf("%d",... Continue Reading →

Automorphic number in C

An Automorphic number is a number whose square ends with the same digits as the original. example: 5, 6 etc. #include <stdio.h> #include <stdlib.h> #include <math.h> int main() { int num, square, temp, last; int n =0; printf("Enter a number \n"); scanf("%d",&num); square = num*num; temp = num; while(temp>0){ n++; temp = temp/10; } int den =... Continue Reading →

C program to swap 2 numbers without using 3rd variable

It can be done using two methods: By using + and -By using * and / Method 1: By using + and - #include<stdio.h> int main() { int num1, num2; printf("Enter first number: ") ; scanf("%d",&num1); printf("\nEnter second number: ") ; scanf("%d",&num2); printf("\n Before swapping \n number_1= %d \n number_2 = %d",num1,num2); num1=num1+num2; num2=num1-num2; num1=num1-num2;... Continue Reading →

Easy Python programs

Print the ASCII value of Characters charr =(input("Enter a charcater")) print("The ASCII value of '" + charr + "' is", ord(charr)) Find the roots of quadratic equation import cmath a = int(input("Enter the value of a ")) b = int(input("Enter the value of b ")) c = int(input("Enter the value of c ")) # calculating... Continue Reading →

Area and Circumference of circle in python

#area and circumference of circle rad=float(input("Enter the radius of the circle ")) area= 3.14*rad*rad print("Area of the circle of given radius is = ", area) circum= 2*3.14*rad print("Circumference of the circle of given radius is = ", circum)

To check for Armstrong number in C

Armstrong number is a number which is equal to the sum of cubes of its digits. e.g. 0, 1, 153 etc are the Armstrong numbers. Demonstration: 153=(1*1*1)+(5*5*5)+(3*3*3) cube of 1=1 cube of 5=125 cube of 3=27 1+125+27=153 #include<stdio.h> int main() { int n,q,sum=0,temp; printf("Enter a number="); scanf("%d",&n); temp=n; while(n>0) { q=n%10; sum=sum+(q*q*q); n=n/10; } if(temp==sum) printf("The given... Continue Reading →

Calculate Compound Interest using Python

Formula for compound interest : =final amount=initial principal balance=interest rate=number of times interest applied per time period=number of time periods elapsed def compound_interest(principle, rate, time): CI = principle * (pow((1 + rate / 100), time)) print("Compound interest : ", CI) p=int(input("Enter Principal amount: ")) r=int(input("Enter interest rate: ")) t=int(input("Enter time period: ")) compound_interest(p, r, t)

Calculate simple interest using python

Formula for simple interest is : (principal amount* rate of interest* time period)/100 SI= (P*R*T)/100 p=int(input("Enter the principal amount ")) r=int(input("Enter the interest rate per annum ")) t=int(input("Enter the time period in years ")) simple_interest=(p*r*t)/100 print("SIMPLE INTEREST = ", simple_interest)

Fibonacci Series

Fibonacci series is a series of numbers in which each number ( Fibonacci number ) is the sum of the two preceding numbers. e.g. 0, 1, 1, 2, 3, 5, 8, etc. The Rule is to write a Fibonacci series is: xn = xn−1 + xn−2 where: xn is term number "n"xn−1 is the previous term (n−1)xn−2 is the term before that (n−2)... Continue Reading →

Binomial Coefficient

Binomial coefficient is a positive integer that occur as coefficient in the Binomial Theorem. It can be defined as the coefficient of the monomial Xk in the expansion of (1 + X)n . This coefficient also occurs in the formula given below #include <stdio.h> int Coeff(int n, int k) { if (k > n) return 0; if (k... Continue Reading →

Factorial of a Big Number

#include<stdio.h> int main() { int arr[200],n,count,temp,i; arr[0]=1; count=0; printf("Enter the number whose factorial you want to find: "); scanf("%d",&n); for(; n>=2; n--) { temp=0; for(i=0; i<=count; i++) { temp=(arr[i]*n)+temp; arr[i]=temp%10; temp=temp/10; } while(temp>0) { arr[++count]=temp%10; temp=temp/10; } } for(i=count; i>=0; i--) printf("%d",arr[i]); return 0; }

HCF and LCM

HCF can be defined as the Highest Common Factor. It means the greatest which can exaclty divide the given numbers without the remainder. It is also known as Greatest Common Divisor (GCD). Program to find the HCF of 2 numbers. #include <stdio.h> int main() { int num1, num2, i, hcf; printf("Enter two numbers whose HCF... Continue Reading →

Create a website or blog at WordPress.com

Up ↑

Design a site like this with WordPress.com
Get started