wordsclank.in: programming
Showing posts with label programming. Show all posts
Showing posts with label programming. Show all posts

Monday, 29 October 2018

Introduction to HTML and HTML Tags

HTML is short for Hyper Text Markup Language which is standard markup language for creating  web pages (electronic documents on world wide web). It was first developed by Tim Berners-Lee in 1990. HTML pages are build through HTML elements and the HTML elements are represented by tags. 


HTML Tags :

HTML tags are building component of HTML page. Tags are used to mark up the start of an HTML element. Tags are enclosed with angular brackets such as < b >< /b >, <  img > etc. Generally they come in pair.


 < tag > Content here... < /tag >

is known as opening tag and the angular bracket with backslash is known as closing tag.
The content withing the opening and the closing tag will be executed according to the tagname by the browser.






Lets begin with a simple code :

<! DOCTYPE html >
< html >
< head >
 < title > HTML < /title >
< head >
< body >
< p >Welcome to HTML Tutorials by < b >< i>wordsclank < /i >< /b > < /p >
< /body >
< /html >

Explanation:

  • < ! DOCTYPE html > is not an HTML tag. It only instruct the web browser about the version  HTML the page is written in.
  • < html > is the container of all other elements.< /html >
  • < head > is the container for meta data or data about data like document title, character set, styles, links, scripts, and other meta information.< /head >
  • The content between < title > and < /title > is shown on browser's title bar.
  • Within the < body > and < /body > tag all your code or the main content will be written.
  • < p > tag is used for paragraphs.
  • < b > < i > tags are for bold and italic.

Browsers view :









Read more ...

Friday, 13 April 2018

C Program to find Perfect Numbers between intervals given by user

What is Perfect Number? 


www.wordsclank.inperfect number is a positive integer that is equal to the sum of its proper positive divisors, that is, the sum of its positive divisors excluding the number itself (also known as its aliquot sum).


Also, a perfect number is that number whose sum of its proper positive divisor(including the number itself) is equals to the twice the number.


For example 28,
divisor of 28:1,2,4,7,14,28

sum of divisors(excluding the number itself):1+2+4+7+14=28 i.e, equals to the number 28.

or, sum of divisors(including the number itself):1+2+4+7+14+28=56 i.e, equals to twice the number(2 * 28 = 56).


Logic behind the program:

  • Take the two intervals from the user.
  • Run a for loop from i to last interval, where i is first interval and increment  i by 1 in each iteration.
  • Withing that for loop run another for loop which will find the perfect numbers and print it.

Similar Problem:


Problem Statement:

Write a program in C which will find all the perfect numbers between two intervals given by the user.






Source Code:

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
#include

void main()

 {

   int i, j, beg, end, sum;

   printf("Enter the first interval:");

   scanf("%d", &beg);
   
   printf("Enter the last interval:");

   scanf("%d", &end);
   

   for(i = beg; i<=end; i++)

   {
     sum = 0;
     
     for(j=1; j<i; j++)
     
     {

   if(i % j == 0)

                 sum = sum + j;
          
             }

     if( sum == i) 

             {

                  printf("%d \t",i);

             }
}


 }

Output:



More Topics on C program


Read more ...

Tuesday, 13 March 2018

C program to store information of n student using structure

A structure is a user defined data type available in C that helps to combine a lot of different data type under a single name which is easier to handle.
For example: A structure student which will store roll number of integer data type, name of character data type, marks of float type.
structure,structure in c

Problem statement:

C program to store information of n student using structure



Source code

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
#include

struct student
{
 char name[100];
 int roll;
 float mark;
}str[100];

int main()
{
 int n, i;
 printf("Enter the number of student: ");
 scanf("%d",&n);
 
 printf("Enter the informations of the student:\n");
 
 for(i=0;i<n;i++)
 {
  str[i].roll = i+1;
  
  printf("For roll number %d \n",str[i].roll);
  
  printf("Enter name: ");
  scanf("%s", str[i].name);
  
  printf("Enter marks: ");
  scanf("%f",&str[i].mark);
  
  printf("\n");
 }
 
 printf("The information of %d students are as follows:\n",n);
 for(i=0;i<n;i++)
 {
  printf("Roll number : %d\n",i+1);
  printf("Name:");
  puts(str[i].name);
  printf("Marks:%f",str[i].mark);
  printf("\n");
 }
 return 0;
}



Output

structure, structure in c
Read more ...

Sunday, 11 March 2018

C program to find the length of a string without strlen( ) function

This program calculates the length  of a string manually using a for loop.We are not using strlen( ) over here.
string, strlen(), String in C



SOURCE CODE

1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
#include
int main()
{
    char i, str[100];

    printf("Enter the string: ");
    scanf("%s", str);

    for(i = 0; str[i] != '\0'; i++);
    
    printf("Length of string: %d", i);
    return 0;
}

OUTPUT

string,string in c,strlen()

Explanation:

Here within the main() we have declared one character variable i and one character string srt[].Then we print a message for the user to input the string and stores it in str[]. Then we are running a for loop which run from i=0 until str[i]!='/0' i.e, null and it will count the i i.e, the number of elements in the string.Next we just print the value of i , i.e, the number of elements in the string.

More Topics on C program

Read more ...

Saturday, 10 March 2018

C program to find the Armstrong Number between intervals

A  number of n digit is called Armstrong number if sum of the power of n of its digits is equal to the number itself.
For example a number of three digits integer is an Armstrong number if the sum of the cubes of its digits is equal to the number itself. 153 is an Armstrong number since 1*1*1 + 5*5*5 + 3*3*3 = 371. 
armstrong number,armstrong number in C


Most Related:

PROBLEM STATEMENT

Write a program in C to find the Armstrong Number between intervals.




SOURCE CODE


 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
#include
#include

int main()
{
    int a, b, i, num1, num2, rem, n = 0, result = 0;

    printf("Enter the first interval: ");
    scanf("%d", &a);
    printf("Enter the last interval: ");
    scanf("%d", &b);
    printf("Armstrong numbers between %d and %d are: ", a, b);

    for(i = a + 1; i <= b; i++)
    {
        num1 = i;
        num2 = i;

        //checking number of digits
        while (num1 != 0)
        {
            num1 = num1 / 10;
            n++;
        }

        while (num2 != 0)
        {
            rem = num2 % 10;
            result = result + pow(rem, n);
            num2 = num2 / 10;
        }

        if (result == i) 
 {
            printf("%d ", i);
        }
        n = 0;
        // setting n as o for next iteration
        result = 0;

    }
    return 0;
}



OUTPUT

armstrong number,armstrong number in C

Read more ...

Thursday, 8 March 2018

C program to check whether a certain number is Armstrong or not

A  number of n digit is called Armstrong number if sum of the power of n of its digits is equal to the number itself.
For example a number of three digits integer is an Armstrong number if the sum of the cubes of its digits is equal to the number itself. 153 is an Armstrong number since 1**3 + 5**3 + 3**3 = 371. 
armstrong number in C,armstrong number


Most Related:






SOURCE CODE



 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
60

#include
#include


int main()

{

    int num, rem, altnum, result = 0, n = 0 ;


    printf("Enter an integer: ");

    scanf("%d", &num);


     altnum = num;

    

    while (altnum != 0)

    {

        altnum /= 10;

        n++;

    }


    altnum = num;


    while (altnum != 0)

    {

        rem = altnum % 10;

        result = result + pow(rem, n);

        altnum /= 10;

    }


    if(result == num)

        printf("%d is an Armstrong number.", num);

    else

        printf("%d is not an Armstrong number.", num);


    return 0;

}



OUTPUT

armstrong number,armstrong number in C


Read more ...

Sunday, 4 March 2018

C Program to Check Whether a Number is Palindrome or Not

palindromic number is a number that remains the same when its digits are reversed.The term palindromic is derived from palindrome, which refers to a word (such as rotor or racecar) whose spelling is unchanged when its letters are reversed.
For example:12321 is same when its digits are reversed.


Palindrome number,Palindrome number in C






SOURCE CODE

 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
60
61
62
63
64
65
66
67
68
69
#include
#include

void main()


{


    int num, i, reverse = 0, temp, rem;


    printf("Enter number: ");


    scanf("%d",&num);


    temp = num;


    while(num ! = 0)


    {


       rem = num % 10;


       num = num / 10;


       reverse=rem+(reverse*10);


    }


    if(reverse==temp)


    {


       printf(" Palindrome Number");


    }


    else


    {


       printf("Not a Palindrome Number");


    }


   getch();


}


OUTPUT

palindrome number,palindrome number in C

Read more ...

Saturday, 3 March 2018

C Program to display the Fibonacci Series up-to n number of terms

Before we start coding lets know what exactly Fibonacci Sequence is?
A series of a number in which each number is sum of the two preceding numbers.
For example,  1,1,2,3,5,8,13,21,34,55,89.. is the simplest fibonacci series.

Fibonacci Sequence,Fibonacci Sequence in c

Most related






SOURCE CODE


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
#include< stdio.h>

void main()
{
 int i, n, a = 0, b = 1, nxt;
 printf("Enter the number of terms: \n");
 scanf("%d",&n);
 
 printf("The Fibonacci series upto %d term is:\n",n);
 
 for(i = 1; i <= n; i++)
 {
  printf("%d \t",a);
  nxt = a + b;
  a = b;
  b = nxt;
 }
}


OUTPUT

Fibonacci Sequence,Fibonacci Sequence in C

Related Topics




  • C program to store information of n student using structure
  • C program to find the length of a string without strlen( ) function
  • C program to find the Armstrong Number between intervals
  • C program to check whether a certain  number is Armstrong or not
  • C Program to Check Whether a Number is Palindrome or Not
  • C Program to display the Fibonacci Series up-to a certain number
  • C program to find the factorial of a number
  • C Program to Find Prime Numbers Between Intervals Using Functions.
  • C program: perfect or not checking
  • C program to identify a number as even or odd



  • Read more ...

    C Program to display the Fibonacci Series up-to a certain number

    Before we start coding lets know what exactly Fibonacci Sequence is?
    A series of a number in which each number is sum of the two preceding numbers.
    For example,  1,1,2,3,5,8,13,.. is the simplest fibonacci series.

    wordsclank.blogspot.com
    Most related






    SOURCE CODE

    >
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    #include<stdio.h>
    void main()
    {
     int i, n, a=0, b=1, nxt;
     
     printf("Enter the number:\n");
     scanf("%d",&amp;n);
     
     printf("The Fibonacci series is: 1, \t ");
     // first two term will always 1
     
     nxt = a + b;
     
     while(nxt &lt;= n)
     {
      printf("%d, \t",nxt);
      a = b;
      b = nxt;
      nxt = a + b;
     }
     
    }
    

    OUTPUT

    Words Clank,wordsclank

    Explanation

    Within the main() function first we declarer i, n, a=0, b=1, nxt  as integer variable.Next we display a message for the user to give input.Then we store the value given by the user in n.Then again we display a message that  "The Fibonacci series is: 1, ".Here we have already printed the first term as 1 because we know that the first term of a Fibonacci series is always 1.Then in nxt we store the value of a+b.Then  we are running a  while loop that will run until nxt less then equall to number n.Within the loop first we are printing the value of nxt then we are assigning the value of a to b and then we are assigning the value of nxt to b and then again we are assigning the value of nxt as a+b.

    Related Topics

    Read more ...

    C program to find the factorial of a number

    Before we start coding lets have a brief look on what factorial really means.?
    The factorial of a integer n is nothing but the product of the integer and all the integer below it.
    For example n!=(n)*(n-1)*(n-2)...*2*1
     or, n!=1*2*3*4....(n-1)*n
    note that 0!=1
    wordsclank.bmlogspot.co





    SOURCE CODE


    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
    #include<stdio.h>
    void main()
    {
     int i, num;
     int factorial;
     
     printf("Enter the integer :\n");
     scanf("%d",&num);
     if(num > 0)
     {
      for(i = 1; i <= num; i++)
      {
       factorial = factorial * i;
      }
      printf("The factorial of %d is %d",num,factorial);
     }
     else if(num == 0)
     {
      printf("The factorial of %d is 1",num,factorial);
      //0! is always 1
     }
     else
     {
      printf("Error! Negative number's factorial doesnt exist. Enter a positive number:\n");
      //error message for user for entering negavitive number
     }
     
    }
    

    OUTPUT


    wordsclank.blogspot.com

    Explanation

    Within the main function first we declared three integer variable i , n and factorial . Next we display a message to take input from the user and store it to the integer variable n.Next we use a if -else conditional checking that will check the number as positive or negative. If the number is negative then it will display a  message that "Error! Negative number's factorial doesn't exist. Enter a positive number:".And if the number is positive it will continue.Then under the for loop it will multiply number and numbers below it one by one and store it in factorial integer variable.when the controls comes out of the loop then it will display it.
    I

    Related Topics



    Read more ...

    Monday, 29 January 2018

    C Program to Find Prime Numbers Between Intervals Using Functions.


    A Prime number an integer which is divisible only by 1 and itself.In other word a whole number who have two factor 1 and the number itself.
    For example 2, 3, 5, 7, 11, 13, 17, 23, ...

    prime number, prime number in c


    Here we make a user defined function primecheck() that will check and print all the prime numbers between the given interval.

    PROBLEM STATEMENT:

    Write a  Program in C to find prime numbers between intervals using functions.





    SOURCE CODE:


     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
    60
    61
    62
    #include
    
    void primecheck(int x,int y);
    
    void main()
    
    {
    
          int n, m;
    
          printf("Enter the first number:");
    
          scanf("%d",&n);
    
          printf("Enter the secound number:");
    
          scanf("%d",&m);
    
          primecheck(n, m);
    
    }
    
    
    void primecheck(int x,int y)
    
    {
    
          int i,count=0,j;
    
          for(i = x; i <= y; i++)
    
          {
    
                for(j=1; j <= i; j++)
    
                {
    
      
    
                      if(i%j==0)
    
                      {
    
                            count = count + 1;
    
                      }
    
                }
    
           if(count == 2)
    
           {
    
                 printf("%d",i);
    
           }
    
           count=0;
    
          }
    
    }
    


    OUTPUT:
    prime number, prime number in c

    If the user's first number is greater than the second number then the numbers need to be swapped first.


    More topics on C programming:




      Read more ...

      Wednesday, 12 April 2017

      Visual Basic 6 | Convention of Fahrenheit and Celsius at a same time with Scroll Bar

      Guys
      In this post we will discuss another funny as well as interesting program in Visual Basic i.e, making temperature scale with Scroll Bar where both the Fahrenheit and Celsius will change at a same time .

      Scroll bar control is vary good tools for the programmers of Visual basic.It is vary essay to use,It is of two form horizontal and vertical.We can place it in form according to our needs or choices.

      We have done our design in such a way
      Fahrenheit and Celsius,Visual Basic
      We took four labels only and a scroll option.






      Changed Property
                Label1:
                        caption :Fahrenheit
                Label2:
                        caption: Celsius
                HScroll1:
                        maximum:100
                        minimum:0

      Problem Statement:
           Write a program in Vb to convert Fahrenheit and Celsius at a same time using scroll bar.

      Source Code:
      Private Sub Vscroll1_Change( )
      
               Dim C as Integer
      
               Dim F as Integer
      
                  Label1.Caption = VScroll1.Value
      
                    C = Val(Label1.Caption)
      
                    F = 9/5*C + 32
      
                  Label2.Caption =  F
      
            End Sub
      


      • The source code is written under Change event of VScroll. 
      • Dim is used to declared a variable.
      • Val function is used to change a string to numeric.

      Thanks for reading this post.Hope this will help you.
      If you have any doubt comment bellow , we will be happy to help you.

      Read more ...

      Sunday, 9 April 2017

      Visual Basic | Fibonacci Sequence

      Guys..
      We are going to generate Fibonacci sequence in Vb.Fibonacci series is the series in the the first term starts from 0 and next term will be addition of the previous two terms.

      we will design the form in which we will take one text box for taking the input up-to which the series will be generated and one command button.

      Fibonacci series, Visual Basic
      we will write the code under the click event of command button.







      SOURCE CODE


      Private Sub Command1_Click( )


      Dim  n, a, b, c as Integer

      n = val(Text1.Text)

        a =0

        b =1

        Print a

        Print b

       For i = 1 To n - 2

          c = a + b

          a = b

          b = c

          Print c

       Next i

      End Sub




      NOTE:
       1.The program uses if next loop structure.
       2.Dim is used to declared a variable.
       3.Val function is used to change a string to numeric.

      Thanks for reading the post.Hope this will help you.If you have any doubts comment on the comment section, we will be happy to help you.
      Read more ...