Skip to main content

Posts

Search This Blog

matrix multiplication in c using functions and pointers

 #include <stdio.h> #define ROWS 3 #define COLS 3 void matrixMultiply(int *mat1, int *mat2, int *result, int rows1, int cols1, int cols2) {     int i, j, k;     // Multiplying matrices     for (i = 0; i < rows1; i++) {         for (j = 0; j < cols2; j++) {             *(result + i * cols2 + j) = 0;             for (k = 0; k < cols1; k++) {                 *(result + i * cols2 + j) += *(mat1 + i * cols1 + k) * *(mat2 + k * cols2 + j);             }         }     } } void displayMatrix(int *mat, int rows, int cols) {     int i, j;     // Displaying matrix     for (i = 0; i < rows; i++) {         for (j = 0; j < cols; j++) {             printf("%d\t", *(mat + i * cols + j));         }         printf("\n");     } } int main() {     int mat1[ROWS][COLS] = {{1, 2, 3},                             {4, 5, 6},                             {7, 8, 9}};     int mat2[ROWS][COLS] = {{9, 8, 7},                             {6, 5, 4},                             {

27 October History: The world got sewing machine on this day, India gave 'Agni test' for missile power

  Trending News: 27 अक्टूबर को इतिहास के चश्मे से देखें तो यह दिन कई मायनों में खास है. एकतरफ दुनिया को जहां आज ही के दिन मशीन जैसी चीज मिली थी तो भारत ने अग्नि-5 मिसाइल का परीक्षण भी आज ही किया था. Trending News: If you look at the prism of history on October 27, then this day is special in many ways. On one hand, where the world got a machine-like thing on this day, India had also tested Agni-5 missile today. 27 अक्टूबर ऐतिहासिक घटनाएँ: अक्टूबर का महीना खत्म होने की कगार पर है और नवंबर दस्तक देने वाला है। अक्टूबर आमतौर पर कई त्योहारों का गवाह बनता है, लेकिन इतिहास के नजरिए से देखा जाए तो यह महीना कई मायनों में खास है। अगर 27 अक्टूबर की बात करें तो इस दिन के अंदर भी कई इतिहास हैं। आइए जानते हैं कुछ ऐसे ही अहम पलों के बारे में जो आस से जुड़े हैं। 27 October Historical Events: The month of October is on the verge of ending and November is about to knock. October usually witnesses many festivals, but even if seen through the prism of history, this month is special in many ways. If we ta

Here you get a leave from the office to have a physical relationship, know why the government has made this unique rule

Here you get a leave from the office to have a physical relationship, know why the government has made this unique rule   There is an official holiday for having a physical relationship, are you surprised to read the headline? But this is true. There is a country where people get leave to have physical relationship. Let us tell about that country and what is the reason behind it. Relationship Desk . The meeting of two hearts or the establishment of a physical relationship between them is a moment. Why would a leave be given for this? But you will find it strange to know that there is a country where the government has made a provision of leave for this. People get leave from office to have sex. The name of that country is Denmark. Yes, this facility has been given to the people in this country. Actually, the decreasing population of Denmark has been a matter of concern for the government there. From time to time, the government there runs such campaigns. Due to which people get the fee

what is Algorithm || how to write Algorithm || Algorithm kaise likhte hai

 Criteria to be followed by an Algorithm The following is the criteria to be followed by an algorithm :  • Input : There should be zero or more values which are to be supplied.  • Output : At least one result is to be produced.  • Definiteness : Each step must be clear and unambiguous.  • Finiteness : If we trace the steps of an algorithm, then for all cases, the algorithm must terminate after a finite number of steps.  • Effectiveness : Each step must be sufficiently basic that a person using only paper and pencil can in principle carry it out. In addition, not only each step is definite, it must also be feasible Example  Let us try to develop an algorithm to compute and display the sum of two numbers  1. Start  2. Read two numbers a and b  3. Calculate the sum of a and b and store it in sum  4. Display the value of sum  5. Stop   #include<stdio.h> #include<conio.h> void main(){ int a,b,sum; printf("Enter Any Two Number : "); scanf("%d%d",&a,&b)

C Program to Check Armstrong Number

Before going to write the c program to check whether the number is Armstrong or not, let's understand what is Armstrong number. Armstrong number  is  a number that is equal to the sum of cubes of its digits . For example 0, 1, 153, 370, 371 and 407 are the Armstrong numbers. Let's try to understand why  153  is an Armstrong number. 153 = (1*1*1)+(5*5*5)+(3*3*3)   where:   (1*1*1)=1   (5*5*5)=125   (3*3*3)=27   So:   1+125+27=153   Example of second no  371 = (3*3*3)+(7*7*7)+(1*1*1)   where:   (3*3*3)=27   (7*7*7)=343   (1*1*1)=1   So:   27+343+1=371   This program computes all Armstrong numbers in the range of ! 0 and 999. An Armstrong number is a number such that the sum ! of its digits raised to the third power is equal to the number ! itself. For example, 371 is an Armstrong number, since ! 3**3 + 7**3 + 1**3 = 371.  #include<stdio.h> #include<conio.h> int main(void){ int a,a2,a3,a4,b,b2,b3,c,i,j; printf("Enter any number :"); scanf("%d&quo

how to multiple number enter and sort the Ascending Order

how to multiple number enter and sort the Ascending Order #include<Stdio.h> #include<conio.h> int main(void){ int a[10],b,c,n,i,j; printf("Enter number of elements :"); scanf("%d",&n); for(i=1; i<=n; i++){ printf("Enter any number :"); scanf("%d",&a[i]); } for(i=1; i<=n; i++){ for(j=i+1; j<=n; j++){ if(a[i]>a[j]){ b=a[i]; a[i]=a[j]; a[j]=b; } } } printf("Ascending Order :\n"); for(i=1; i<=n; i++){ printf("%d\t",a[i]); } getch(); }

how to add n number of element of array

how to add n number  of element of array   how to  Addition the elements of array #include<stdio.h> #include<conio.h> int main(void){ int a[10],b,i,sum; printf("Enter number of elements to add :"); scanf("%d",&b); sum=0; for(i=1; i<=b; i++){ printf("Enter values :"); scanf("%d",&a[i]); sum=sum+a[i]; } printf("Result :%d",sum); getch(); }

what is programming language

 what is programming language You must appreciate the fact that programming languages ​​are created by us humans. These languages ​​are used to communicate instructions to machines, especially computers, so that programs can control the behavior of the machines' hardware to achieve the desired results.  Basically, the hardware of the computer understands only the language of the hardware which is called as machine language. The hardware is unable to understand and understand a program written in another programming language. In addition, each type of CPU has its own machine language. Therefore, in order for the computer's hardware to understand the instructions contained in a program written in another programming language, a mechanism is needed, called a 'translator'. It converts programs written in programming languages ​​other than the native machine language of the CPU (hardware) into the native machine language of a particular CPU on which this program is intended

Contact Form

Name

Email *

Message *