Binary to Decimal in C program
//Binary to Decimal in C program #include <stdio.h> main() { int num, binary_val, decimal_val = 0, base = 1, rem; printf("Enter a binary number(1s and 0s) \n"); …
Binary to Decimal in C program Read More//Binary to Decimal in C program #include <stdio.h> main() { int num, binary_val, decimal_val = 0, base = 1, rem; printf("Enter a binary number(1s and 0s) \n"); …
Binary to Decimal in C program Read More//for statement #include<stdio.h> #include<conio.h> int main() { int n,i,flag=0; printf("ENter a positive integer:"); scanf("%d",&n); for(i=2;i<n/2;i++) { if(n%i==0) { flag=1; break; } } if(flag==0) printf("%d is a prime number",n); else printf("%d …
Prime or Not Using for statement in C program Read More//using while statement #include<stdio.h> int main() { int a,b,x,y,t,gcd,lcm; printf("Enter two integer:\n"); scanf("%d%d",&x,&y); a=x; b=y; while(b!=0) { t=b; b=a%b; a=t; } gcd=a; lcm=(x*y)/gcd; printf("Greatest common divisor of %d amd %d=%d\n",x,y,gcd); …
HCF and LCM using while statement in C Program Read More//print number entered and find sum using do while #include<stdio.h> #include<conio.h> int main() { int n,i=1,sum=0; printf("Enter the value of N:"); scanf("%d",&n); printf("First %d numbers are\n",n); do { printf("%7d",i); sum=sum+i; …
Print numbers entered and find sum using do while statement in C program Read More//using while statement #include<stdio.h> #include<conio.h> main() { int n,m,r,p=1,t=0; printf("Enter any decimal number:"); scanf("%d",&n); m=n; while(n!=0) { r=n%2; t=t+(r*p); n=n/2; p=(p*10); } printf("Decimal Number %d=Binary Number:%d",m,t); } DECIMAL To BINARY …
Decimal to Binary using while statement in C program Read More//multiplication table #include<stdio.h> #include<conio.h> main() { int i,j,p; printf("The Multiplication table of 1 to 10 is:"); for (i=1;i<=10;i++) { for(j=1;j<10;j++) { p=i*j; printf("%d*%d=%d\n",i,j,p); } printf("\n"); } getch(); }
multiplication table in C program Read More//input 10 integer and find total #include<stdio.h> #include<conio.h> main() { int num[10],i,total=0; for(i=0;i<10;i++) { printf(“input interger number:”); scanf(“%d”,&num[i]); } for(i=0;i<10;i++) { total=total+num[i]; } printf(“Total of 10 integer numbers=%d”,total); }
input integer in array and find total in C program Read More//transpose of matrix //transpose of matrix #include<stdio.h> #include<conio.h> #define ROWS 3 #define COLS 3 int main(void) { int a[ROWS][COLS]={{1,2,3},{4,5,6},{7,8,9}}; int i,j,tmp; for(i=1;i<ROWS;i++) { for (j=0;j<COLS;j++) { tmp=a[i][j]; a[i][j]=a[j][i]; a[j][i]=tmp; } …
transpose of matrix in C Program Read More//enter elements of 4×4 matrix and find sum #include<stdio.h> #include<conio.h> main() { int a[4][4],b[4][4],sum[4][4],i,j; for(i=0;i<4;i++) { for(j=0;j<4;j++) { printf("input the elemebt of matrix a:"); scanf("%d",&a[i][j]); } } for(i=0;i<4;i++) { for(j=0;j<4;j++) …
Enter elements of 4×4 matrix and find sum of the elements of matrix in C program Read More//compare string #include<stdio.h> #include<conio.h> #include<string.h> main() { char str1[10],str2[10]; printf("input first string:"); scanf("%s",str1); printf("input second string:"); scanf("%s",str2); if(strcmp(str1,str2)==0) { printf("Both %s and %s are same",str1,str2); } else if (strcmp(str1,str2)>0) { …
Compare two String function in C Program Read More