Thursday, April 30, 2015
Wednesday, April 29, 2015
Tuesday, April 28, 2015
Prime without Loop
#include<stdio.h>
void main()
{
int no,i=2,cnt=0;
printf("Enter no :");
scanf("%d",&no);
start :
if(i>=no)
{
goto end;
}
else
{
if(no%i==0)
{
cnt++;
}
i++;
}
end:
if(cnt==0)
{
printf("\n Prime no");
}
else
{
printf("\n Not prime no");
}
}
void main()
{
int no,i=2,cnt=0;
printf("Enter no :");
scanf("%d",&no);
start :
if(i>=no)
{
goto end;
}
else
{
if(no%i==0)
{
cnt++;
}
i++;
}
end:
if(cnt==0)
{
printf("\n Prime no");
}
else
{
printf("\n Not prime no");
}
}
Binary to Decimal
/* C programming source code to convert either binary to decimal or decimal to binary according to data entered by user. */
#include <stdio.h>
#include <math.h>
int binary_decimal(int n);
int decimal_binary(int n);
int main()
{
int n;
char c;
printf("Instructions:\n");
printf("1. Enter alphabet 'd' to convert binary to decimal.\n");
printf("2. Enter alphabet 'b' to convert decimal to binary.\n");
scanf("%c",&c);
if (c =='d' || c == 'D')
{
printf("Enter a binary number: ");
scanf("%d", &n);
printf("%d in binary = %d in decimal", n, binary_decimal(n));
}
if (c =='b' || c == 'B')
{
printf("Enter a decimal number: ");
scanf("%d", &n);
printf("%d in decimal = %d in binary", n, decimal_binary(n));
}
return 0;
}
int decimal_binary(int n) /* Function to convert decimal to binary.*/
{
int rem, i=1, binary=0;
while (n!=0)
{
rem=n%2;
n/=2;
binary+=rem*i;
i*=10;
}
return binary;
}
int binary_decimal(int n) /* Function to convert binary to decimal.*/
{
int decimal=0, i=0, rem;
while (n!=0)
{
rem = n%10;
n/=10;
decimal += rem*pow(2,i);
++i;
}
return decimal;
}
#include <stdio.h>
#include <math.h>
int binary_decimal(int n);
int decimal_binary(int n);
int main()
{
int n;
char c;
printf("Instructions:\n");
printf("1. Enter alphabet 'd' to convert binary to decimal.\n");
printf("2. Enter alphabet 'b' to convert decimal to binary.\n");
scanf("%c",&c);
if (c =='d' || c == 'D')
{
printf("Enter a binary number: ");
scanf("%d", &n);
printf("%d in binary = %d in decimal", n, binary_decimal(n));
}
if (c =='b' || c == 'B')
{
printf("Enter a decimal number: ");
scanf("%d", &n);
printf("%d in decimal = %d in binary", n, decimal_binary(n));
}
return 0;
}
int decimal_binary(int n) /* Function to convert decimal to binary.*/
{
int rem, i=1, binary=0;
while (n!=0)
{
rem=n%2;
n/=2;
binary+=rem*i;
i*=10;
}
return binary;
}
int binary_decimal(int n) /* Function to convert binary to decimal.*/
{
int decimal=0, i=0, rem;
while (n!=0)
{
rem = n%10;
n/=10;
decimal += rem*pow(2,i);
++i;
}
return decimal;
}
How to solve SQL Server Database File Open Error
"Failed to generate a user instance of SQL Server
due to a failure in starting the process for the
user instance. The connection will be closed."
After my fun with trying to get VS, SQL and Phone Tools all working together, I had the
following error trying to mount databases:
"Failed to generate a user instance of SQL Server due to a failure in starting the
process for the user instance. The connection will be closed."
If you get that error message, the solution that worked for me was to clear the SQL Express
user instance data store, located at:
%userprofile%\AppData\Local\ Microsoft\Microsoft SQLServer
Data\SQLEXPRESS
(or full path)
C:\Users\\AppData\Local\ Microsoft\Microsoft SQL ServerData\SQLEXPRESS
Subscribe to:
Comments (Atom)