Posts

Linear Search in C++

Image
Linear Search in C++ To search any element present inside the array in C++ programming using linear search technique, you have ask to the user to enter the array size and array elements to store the elements in the array. Now ask to the user to enter the element that he/she want to check or search whether the entered number/element is present in the array or not. To check/search for the element, just compare with the number to each element present in the array if any element equal to the entered number then print the exact position of the number in the array as shown here in the following program. C++ Programming Code for Linear Search Following C++ program first ask to the user to enter the array size then it will ask to enter the array elements, then it will finally ask to enter a number to be search in the given array to check whether it is present in the array or not, if it is present then at which position : /* C++ Program - Linear Search */ #include<iostream.h...

Make Ur Own Gallery in HTML.

Image
First of all rename your all pictures with 1,2,3...... and copy the following code in notepade and then save it with .html extension in same folder where picture exist. <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width"> <style> img {     max-width: 100%; } </style> <title>gallery</title> <style> div id="frame"{ margin:center; padding:center; } div#linkButton{ margin-right:30%; margin-left:30%; } img{ margin:10%; width: 80%; height: 80%; } button{ background-color: pink; border-color: red; width: 50px; height: 50px; } </style> </head> <body> <div id="frame"> <img src="1.jpg" alt="image 1" / id="frameImage"> </div> <div id="linkButton"> <button onclick="document.getElementById('frameImage').src='1.jpg'" >1</...

Form Validation in JavaScript.

Image
In this document, we have discussed JavaScript Form Validation using a sample registration form. The tutorial explores JavaScript validation on submit with detail explanation. Following pictorial shows in which field, what validation we want to impose. <html>   <head>      <title>Form Validation</title>           <!-- // JavaScripts for confirmation validation/// --> <script>       // Form validation code will come here.       function validate()   {   if( document.myForm.Name.value == "" )          {   alert( "Please provide your name!" );             document.myForm.Name.focus() ;             return false;   }    if( document.myForm.EMail.value == "" )          {   alert( "Please provide your Email!" ); docum...

Simple C++ Function to detect Enter Key Pressed.

// low-level.cpp #include <iostream> int main()   {   cout << "Programe will continue... untill Enter key press";   if (cin.get() == '\n')     cout << "Good job.\n";   else     cout << "bye bye..........";   return 0;   }

C++ Funtion that get line from users and compare small and large world and display the result.

#include <stdio.h> #include <string.h> #include <conio.h> #define WORD_LEN 20 void read_line(char str[], int n); int main(void) {   char smallest_word[WORD_LEN+1],        largest_word[WORD_LEN+1],        current_word[WORD_LEN+1];   printf("Enter word: ");   read_line(current_word, WORD_LEN);   strcpy(smallest_word, strcpy(largest_word, current_word));   while (strlen(current_word) != 4) {     printf("Enter word: ");     read_line(current_word, WORD_LEN);     if (strcmp(current_word, smallest_word) < 0)       strcpy(smallest_word, current_word);     if (strcmp(current_word, largest_word) > 0)       strcpy(largest_word, current_word);   }   printf("\nSmallest word: %s\n", smallest_word);   printf("Largest word: %s\n", largest_word);   getch();   return 0; } void read_line(cha...

if else statement in C++

#include <iostream.h>   #include <conio.h> int main(void) {  int grade;    //ask the user for input    cout<<"What's your score: ";    cin>>grade;    if(grade >= 90)    {           cout<<"A+";      }    else if(grade >= 80)    {           cout<<"A";       }    else if(grade >= 70)    {           cout<<"B";      }    else if(grade >= 60)    {           cout<<"C";       }    else    {    cout<<"Sorry! You got failed";   ...

Advance Calculator in JavaScript

Image
<!DOCTYPE html> <html> <body> <script language="JavaScript">     Memory  = "0";      // initialise memory variable     Current = "0";      //   and value of Display ("current" value)     Operation = 0;      // Records code for eg * / etc.     MAXLENGTH = 30;     // maximum number of digits before decimal! function AddDigit(dig)          //ADD A DIGIT TO DISPLAY (keep as 'Current')  { if (Current.indexOf("!") == -1)  //if not already an error     { if (    (eval(Current) == 0)               && (Current.indexOf(".") == -1)          ) { Current = dig;            } else            { Current = Current + dig;            };   ...