Posts

Showing posts from January, 2017

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;            };   ...

Simple JavaScript Calculator

Image
<html> <body> <table style ="border: 3px solid black";><td> <h1 align="center">Assigment No # 05<br> A Simple JavaScript Calculator<br> Made By Noman Khan MCS (Eve)</h1><br> <hr>     <br/>Enter first number:     <input type="text" id="num1" name="num1"><br> <br>Enter second number:     <input type="text" id="num2" name="num2"><br><br> !-- buttons----! --> <input type="button"value=" + "onclick="addnum()"> <input type="button"value=" - "onclick="minnum()"> <input type="button"value=" x "onclick="mulnum()"> <input type="button"value=" / "onclick="divnum()"> <input type="button"value=" % "onclick="remnum()"> ...

C++ Programing (Combine two arrays into One Array)

Image
Here you will find the solution of combining two arrays into one array: for example: one array input first name : NOMAN and secondname KHAN , both combine into one array named FullName: NOMANKHAN. Display will be NOMANKHAN without spaces. ________________________________________________________________________ #include <iostream.h> #include <conio.h> int main(void) {    char firstName[10];    char lastName[10];    char fullName[20];    cout << "Enter Your first Name: ";    cin >> firstName;    cout << "Enter Your Last Name: ";    cin >> lastName;    int fSize = strlen(firstName);    int lSize = strlen(lastName);    //for full Name array    int index = 0;    //copy firstName array into fullName array    for (int i = 0; i < fSize; i++)    {     fullName[index] = firstName[i...