How to find all name start with N in table in Microsoft SQL Server


Database Name - demo
Table Name - employee

id name      phone      city       salary     company
1 suresh     8100011485 mumbai     20000      abc       
2 subhash    8511144785 kolkata    25000      bcd       
3 nitesh     5844411572 delhi      24000      nhc       
4 nirabh     1245810145 goa        26900      njo       
5 sourav     2544844152 kashmir    24120      lpf       
6 bonny      6245874125 bihar      24500      rfg

Code :
SELECT [id]
      ,[name]
      ,[phone]
      ,[city]
      ,[salary]
      ,[company]
  FROM [demo].[dbo].[employee]
  WHERE name LIKE 'n%'

Output :
id name phone city salary company
3 nitesh    5844411572 delhi      24000      nhc     
4 nirabh    1245810145 goa        26900      njo

IDE Used To Test This Code : Microsoft SQL Server Management Studio 2014

Try this code in your computer for better understanding. Enjoy the code. If you have any Question you can contact us or mail us.We will reply you as soon as possible.

How to show first 3 rows of data in database in Microsoft SQL Server


Database Name - demo
Table Name - employee

id name      phone      city       salary     company
1 suresh     8100011485 mumbai     20000      abc       
2 subhash    8511144785 kolkata    25000      bcd       
3 nitesh     5844411572 delhi      24000      nhc       
4 nirabh     1245810145 goa        26900      njo       
5 sourav     2544844152 kashmir    24120      lpf       
6 bonny      6245874125 bihar      24500      rfg       

Code :
SELECT TOP 3 [id]
      ,[name]
      ,[phone]
      ,[city]
      ,[salary]
      ,[company]
  FROM [demo].[dbo].[employee

Output :
id name      phone      city       salary     company
1 suresh     8100011485 mumbai     20000      abc       
2 subhash    8511144785 kolkata    25000      bcd       
3 nitesh     5844411572 delhi      24000      nhc       

IDE Used To Test This Code : Microsoft SQL Server Management Studio 2014.

Try this code in your computer for better understanding. Enjoy the code. If you have any Question you can contact us or mail us.We will reply you as soon as possible.

Program to calculate Factorial of a Number in C++


Code : 
#include<iostream>
using namespace std;
int main(){
int number, factorial = 1, i;
cout<<"Enter a positive number: ";
cin>>number;
for(i=1;i<=number;i++) {
factorial = factorial *i;
}
cout<<"Factorial is: "<<factorial;
return 0;
}

Output :
Enter a positive number: 3
Factorial is:6

IDE Used To Test This Code : Dev C++.

Try this code in your computer for better understanding. Enjoy the code. If you have any Question you can contact us or mail us.We will reply you as soon as possible.

C program to print 1 to 100 except 60 to 70.


Code : 
#include <stdio.h>
#include <conio.h>
void main() {
int i,n;
for (i=1;i<=100;i++) {

if (i>=60 && i<=70) {
continue;
}
printf("\n%d",i );
}
getch();
}

Output :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100

IDE Used To Test This Code : DEV C++.

Try this code in your computer for better understanding. Enjoy the code. If you have any Question you can contact us or mail us.We will reply you as soon as possible.

Simple Linear Search Programming in JAVA


Code :
package demo;
import java.util.Scanner;
/**
 *
 * @author www.codetheta.com
 */
public class LinearSearch {
    public static void main(String[] args) {
        int array[], elements, elem_search, each_elements, i, flag = 0;
        Scanner in = new Scanner(System.in);
        System.out.println("Enter number of array elements: ");
        elements = in.nextInt();
        array = new int[elements];
        System.out.println("Enter array elements: ");
        for (i=0; i<elements; i++)
            array[i] = in.nextInt();
        
        System.out.println ("Enter element to find: ");
        elem_search = in.nextInt();
        
        for (i=0; i<elements; i++) {
            if (array[i] == elem_search) {
                flag = 1;
                break;
            }
        }
       if (flag == 0) {
           System.out.println("Not Found");
       }
       else {
           System.out.println("Found");
       } 
    }
}

Output :
Enter number of array elements: 
5
Enter array elements: 
4
7
6
2
8
Enter element to find: 
8
Found

IDE Used To Test This Code : NetBeans IDE 8.2

Try this code in your computer for better understanding. Enjoy the code. If you have any Question you can contact us or mail us.We will reply you as soon as possible.

Linear Search Programming in C++


Code :
#include<iostream>
#include<conio.h>
using namespace std;
int main() {
int array[20], elements, elem_search, each_elements, i, flag = 0;
cout<<"How many elements? : ";
cin>>elements;

cout<<"Enter elements list in the array: ";
for (i=0; i<elements; i++)
cin>>array[i];
cout<<"Enter elements you want to search : ";
cin>>elem_search;

for (i=0; i<elements; i++) {
if (array[i] == elem_search) {
flag = 1;
break;
}
}
if (flag == 0) {
cout<<"Not Found";
}
else {
cout<<"Found";
}
}

Output :
How many elements? : 4
Enter elements list in the array: 
4
2
7
5
Enter elements you want to search : 7
Found

IDE Used To Test This Code : DEV C++

Try this code in your computer for better understanding. Enjoy the code. If you have any Question you can contact us or mail us.We will reply you as soon as possible.

How to know Memory Address of a String using Python?


id() is use to access memory address of an object in Python.

Code :
StringOne = "www.codetheta.com"
print ("Memory address is:" ,id(StringOne))

Output :
Memory address is: 45121072

IDE Used To Test This Code : Python IDLE

Try this code in your computer for better understanding. Enjoy the code. If you have any Question you can contact us or mail us.We will reply you as soon as possible.

Two String equal or not using Python program


Using predefined value.
Code :
StringOne = 'www.codetheta.com'
StringTwo = 'ww.codetheta.com'
if StringOne == StringTwo:
    print ("Two Strings are Equal")
else:
    print ("Two Strings are not Equal")

Output :
Two Strings are not Equal

Value given in program runtime
Code :
StringOne = input("Enter first string: ")
StringTwo = input("Enter second string: ")
if StringOne == StringTwo:
    print ("Two Strings are Equal")
else:
    print ("Two Strings are not Equal")

Output :
Enter first string: codetheta
Enter second string: codetheta
Two Strings are Equal

IDE Used To Test This Code : Python IDLE.

Try this code in your computer for better understanding. Enjoy the code. If you have any Question you can contact us or mail us.We will reply you as soon as possible.

Reverse of a String using Python program


Pre defined value
Code :
String = "www.codetheta.com"
print(''.join(reversed(String)))

Output :
moc.atehtedoc.www

Program execution time string value given.
Code :
String = input("Enter any string: ")
print(''.join(reversed(String)))

Output :
Enter any string: www.codetheta.com
moc.atehtedoc.www

IDE Used To Test This Code : Python IDLE.

Try this code in your computer for better understanding. Enjoy the code. If you have any Question you can contact us or mail us.We will reply you as soon as possible.

Calculate Length of a String using Python


Using predefined string
Code :
String = "www.codetheta.com"
print(len(String))

Output :
17

Value given in run time / program execution time.
Code :
Text = input("Enter a string: ")
print(len(Text))

Output :
Enter a string: www.codetheta.com
17

IDE Used To Test This Code : Python IDLE.

Try this code in your computer for better understanding. Enjoy the code. If you have any Question you can contact us or mail us.We will reply you as soon as possible.

Factorial of a number using Python Programming


Code : 
num = int(input("Enter any number: "))
fact = 1
for i in range(1,num + 1):
    fact = fact * i
print("Factorial result is: ",fact)

Output :
Enter any number: 8
Factorial result is:  40320

IDE Used To Test This Code : Python IDLE.

Try this code in your computer for better understanding. Enjoy the code. If you have any Question you can contact us or mail us.We will reply you as soon as possible.

Calculate Absolute Number using Python program


Code :
Number = int(input("Enter any positive or negative number: "))
if Number < 0:
    Number = (-1) * Number
    print ("Result is: ", Number)
else:
    print ("Result is: ", Number)

Output :
Enter any positive or negative number: -2458
Result is:  2458

IDE Used To Test This Code : Python IDLE.

Try this code in your computer for better understanding. Enjoy the code. If you have any Question you can contact us or mail us.We will reply you as soon as possible.

Program to calculate Prime Number using Python


Code :
Number = int(input("Enter a number to check: "))

if Number > 1:
    for i in range(2,Number):
        if (Number % i) == 0:
            print("Not a prime number.")
            break
    else:
        print("Prime number.")
else:
    print("Not a prime number.")

Output :
Enter a number to check: 57
Not a prime number.

IDE Used To Test This Code : Python IDLE.

Try this code in your computer for better understanding. Enjoy the code. If you have any Question you can contact us or mail us.We will reply you as soon as possible.