Skip to main content

Posts

C program Code to write Automata program

Write a program to half pyramid using 1 and 0 10101 01010 10101 01010 10101   Code: #include<stdio.h> int main(){ int i,j,n; printf("enter a number : "); scanf("%d",&n); for(i=1;i<=n;i++){ for(j=1;j<=n;j++){ if((i%2==0 || j%2==1)&&(i%2==1 || j%2==0)) printf("1"); else printf("0"); } printf("\n"); } } Output:

How to Create WIFI Hotspot from Ubuntu 18.04 on laptop Step by Step

How to create WIFI Hotspot on ubuntu 18.04 laptop to create a WIFI Hotspot in ubuntu 18.04 , you should be first connect via lan. then follow just few steps step1:  click on the top right buttons and click on WiFi option and then click on WiFi setting click on WI-FI setting step2:  first "Turn on" your WIFI and them Click those "three lines" step 3: click on "Turn o WiFi Hotspot" option step4: click ok Turn on the Hotspot now active on your laptop. and you can see the password and network name . thank you. i hope you understand.

C program to swap two number

C program to Swap two Number Code: #include<stdio.h> void main(){ int n1,n2,temp; printf("enter two number :"); scanf("%d %d", &n1,&n2); temp=n1; n1=n2; n2=temp; printf("after swaping two number %d  %d\n",n1,n2); } Output:

Matrix Substruction Using C program

Matrix Substruction Using C program Code: #include<stdio.h> void main(){ int first[100][100],second[100][100],sum[100][100],r,c,i,j; printf("enter row and colume :"); scanf("%d%d", &r,&c); printf("enter first matrix element : \n"); for(i=0;i<r;i++){ for(j=0;j<c;j++){ scanf("%d", &first[i][j]); } } for(i=0;i<r;i++){ for(j=0;j<c;j++){ printf(" %d ", first[i][j]); } printf("\n"); } printf("enter second matrix element : \n"); for(i=0;i<r;i++){ for(j=0;j<c;j++){ scanf("%d", &second[i][j]); } } for(i=0;i<r;i++){ for(j=0;j<c;j++){ printf(" %d ", second[i][j]); } printf("\n"); } printf("substraction  of the two matrix : \n"); for(i=0;i<r;i++){ for(j=0;j<c;j++){ sum[i][j]=first[i][j] - second[i][j]; printf(" %d ",sum[i][j]); } printf("\n"); } } Output:

Matrix Addition using C Program

Matrix Addition using C Program Code:  #include<stdio.h> void main(){ int first[100][100],second[100][100],sum[100][100],r,c,i,j; printf("enter row and colume :"); scanf("%d%d", &r,&c); printf("enter first matrix element : \n"); for(i=0;i<r;i++){ for(j=0;j<c;j++){ scanf("%d", &first[i][j]); } } for(i=0;i<r;i++){ for(j=0;j<c;j++){ printf(" %d ", first[i][j]); } printf("\n"); } printf("enter second matrix element : \n"); for(i=0;i<r;i++){ for(j=0;j<c;j++){ scanf("%d", &second[i][j]); } } for(i=0;i<r;i++){ for(j=0;j<c;j++){ printf(" %d ", second[i][j]); } printf("\n"); } printf("substraction  of the two matrix : \n"); for(i=0;i<r;i++){ for(j=0;j<c;j++){ sum[i][j]=first[i][j] - second[i][j]; printf(" %d ",sum[i][j]); } printf("\n"); } } Output:

Create a Dynamic Matrix using C Program

Create a Dynamic Matrix using C Program Code: #include<stdio.h> void main(){ int a[100][100],r,c,i,j; printf("enter row and colume :"); scanf("%d%d", &r,&c); printf("enter matrix element : \n"); for(i=0;i<r;i++){ for(j=0;j<c;j++){ scanf("%d", &a[i][j]); } } for(i=0;i<r;i++){ for(j=0;j<c;j++){ printf("%d", a[i][j]); if(j==c-1){ printf("\n"); } } } } Output:

Create a simple static Matrix using C programming

Create a simple static Matrix using C programming Code: #include<stdio.h> void main(){ int a[2][2]={{1,2}, {3,4}}; int i,j; for(i=0;i<2;i++){ for(j=0;j<2;j++){ printf("%d", a[i][j]); if(j==1){ printf("\n"); } } } } Output: