Posts

setTimeout in Javascript (24 th April 2022 : Sunday Class)

  <!DOCTYPE html > <html lang = "en" > <head>     <meta charset = "UTF-8" >     <meta http-equiv = "X-UA-Compatible" content = "IE=edge" >     <meta name = "viewport" content = "width=device-width, initial-scale=1.0" >     <title> use of array </title>     <script src = "myscript.js" ></script>     <script>         var str= "compuhelp" ;         var ctr=-1;         var mytimer;         function getInput()         {                         //str=prompt("Enter string :");             //alert("your string is " + str);                         // document.write(str); if (ctr<str.length-1) {   ...

2 Dimensional Character Array in C and C++

Image
 //@2D character array in C++ #include<iostream> using namespace std; int main() {     char wdays[7][10];     for(int i=0;i<7;i++)     {         cout<<"Enter weekday: "<<i+1;         cin>>wdays[i];     }     cout<<endl<<"Weekdays are :"<<endl;     for(int i=0;i<7;i++)         cout<<wdays[i]<<endl;     system("pause"); }//end of main Output:

2-Dimensional Array through pointer using C++

//Two Dimensional Array through Pointer in C++  #include<iostream> using namespace std; int main() {  int arr[2][3]={         {10,20,30},         {40,50,60}};         int* ptr;     ptr=(int*)arr;     cout<<sizeof(int);     cout<<endl<<"Values of the array:";     for(int i=0;i<6;i++)         cout<<*(ptr+i)<<" ";     cout<<endl<<"Now Enter 5 values to array:"<<endl;     for(int i=0;i<6;i++)     {         cin>>*(ptr+i);//because cin takes variable name to write not address     }     cout<<endl<<"Again Values of the array:";     for(int i=0;i<6;i++)         cout<<*(ptr+i)<<" ";     return 0; }//end of main

Use of 2-Dimensional Array in C through Pointer

Image
//2D array through pointer  #include<stdio.h> int main() {     int arr[2][3]={         {10,20,30},         {40,50,60}};//initializing 2D array int i; int *ptr;//declaring pointer     ptr=arr;//assigning base address     printf("\nValues of the array:\n");     for(i=0;i<6;i++)     {         printf("%d ",*(ptr+i));     }     printf("\n Enter 5 values to array:\n");     for(i=0;i<6;i++)     {         scanf("%d",(ptr+i));     }     printf("\n\nNow again values of array:\n");     for(i=0;i<6;i++)     {         printf("%d ",*(ptr+i));     }     printf("\n\n\n");         //cout<<**(arr+i)<<" "; return 0; }//end of main      Output:

Use of Character in C Language;

 Q:1 What is Character ? ans:     Character is an alphabet or symbol also like 'a','A','$','#' and '0','9'. Q: How C Language deals with characters. Ans: C Language deals with characters in the form of                               ASCII (American Standard code for Information Interchange) values. Q:What are the ASCII values of 'a','A','0' etc? Ans: ASCII value of 'a' =97, 'A' =65 and 0 = 48 and difference between them is of 32. Q: How we can store a character in C Program? Ans: char ch='a'; Program to use Character in C. #include<stdio.h> int main() {     char ch='a';     int i;     printf("\n value of ch is %c",ch);     printf("\n The ASCII value of a is %d",ch);     ch=ch-32;//putting ASCII value of A     printf("\n Now the value of ch is %c ",ch);     printf("\n ASCII value of A is %d",ch);     ch='0...

Program to demonstrate reference variable in C++

 //Program to demonstrate reference variable in C++ #include<iostream> using namespace std; int main() {     int num=10;     int& x=num;//creating reference of num     cout<<endl<<x;//value of x     cout<<endl<<num;//value of num     cout<<endl<<"address of num is "<<&num;     cout<<endl<<"Address of x is "<<&x;//same as the address of num }//end of main OUTPUT : 10 10 address of num is 0x61fe14 Address of x is 0x61fe14

String Class in C++

 //Use of String class in CPP #include<iostream> #include<string> using namespace std; int main() {     string str1="compuhelp";//using = operator     cout<<endl<<"String is "<<str1;     cout<<endl<<"size of string is "<<str1.size();     cout<<endl<<"Element access "<<str1[0];//displays first char     cout<<endl<<"Element at "<<str1.at(1);//displays second char   cout<<endl<<endl<<"Display String character by character"<<endl;   for(int i=0;i<str1.size();i++)     cout<<str1[i]<<" ";   cout<<endl<<"second method to display string char by char"<<endl;   for(int i=0;i<str1.length();i++)     cout<<str1.at(i)<<" ";     cout<<endl<<"use of substr function of string ";     cout<<endl<<str1.substr(4);//di...

Vector class in C++ (Part of STL)

 //Use of vector template in cpp #include<iostream> #include<vector> using namespace std; int main() {     vector<int> v;     cout<<v.size();//will display size of vector     v.push_back(10);//to add value to vector     v.push_back(20);     cout<<v.size();//will display size after adding values     cout<<endl<<"values of vector"<<endl;     cout<<v[0];//to display first value     cout<<v[1];      cout<<endl<<"values of vector through iterator";    vector<int>::iterator it = v.begin();    while( it != v.end()) {       cout <<endl<<"value of it = " << *it;       it++;    }//end of while    v.push_back(30);    v.push_back(40);    cout<<endl<<"now the size of vector is "<<v.size();   ...

JavaScript Timer Example

  <!DOCTYPE html > <html lang = "en" > <head>     <meta charset = "UTF-8" >     <meta http-equiv = "X-UA-Compatible" content = "IE=edge" >     <meta name = "viewport" content = "width=device-width, initial-scale=1.0" >     <title> Use of JavaScript </title>     <script>         var ctr = 0 ; //initializing ctr         var timer1 = null ;         function msg ( str1 )         {             // alert("hello" + str1);             head1 . innerHTML = "Hello " + str1 ;         }         function increment ()         {             //alert("hello");             ctr = ctr + 1 ;             hea...

Arrow Functions in Javascript

  < html > < head >   < title > Arrow functions </ title >   < script >       var fun = function (){           return "Hello Compuhelp" ;       } //end of function       function test ( f )       {             return f ();       }             function useArrow ()       {         // div1.innerHTML= div1.innerHTML +  fun();         //div1.innerHTML= div1.innerHTML+ test(fun);         const x =( nm ) => "I am arrow function" + nm ;         head3 . innerHTML = x ( "compu" );         //return "hello compu";       }         </ script > </ head > < body > < div id = "div1" > < h2 id = "head2" > Use ...

Java Script Classes

  <! DOCTYPE html > < html lang = "en" > < head >     < title > javascript classes </ title >     < script >         class GMaths         {           constructor ()             {                 this . num1 = 100 ;                 this . num2 = 20 ;             }             /* constructor(n1,n2)             {                 this.num1=n1;                 this.num2=n2;             }*/             setData ( n1 , n2 )             {                 this . num1 ...

First Object Oriented CPP Program

 //my first object oriented cpp program #include<iostream> using namespace std; int x;//variable class Maths {     int num1;//Data member     int num2;     int res;     public:    void getData()//member function     {     cout<<"Enter first number";     cin>>num1;     cout<<"\n Enter second number";     cin>>num2;     }//end of function getData     //num1=10;     //num2=20;     void sum()     {     res=num1+num2;     cout<<"\n The sum of "<<num1<<" and "<<num2<<" is: "<<res;     }//end of function sum }; int main()//non member funtion {     Maths mt;     mt.getData();     mt.sum(); }//end of main

Using Functions in JavaScript

  <! DOCTYPE html > < html lang = "en" > < head >     < meta charset = "UTF-8" >     < meta http-equiv = "X-UA-Compatible" content = "IE=edge" >     < meta name = "viewport" content = "width=device-width, initial-scale=1.0" >     < title > use of functions </ title >         < script >     var arr =[ 10 , 20 , 30 ];             function displayValue ( curObj )         {             // alert(value);             curObj . value = "new Text" ;             ans = sum ( 10 , 20 );             alert ( "The value of ans is " + ans );             addValues ( arr );         }         function sum ( n1 , n2 )     ...

Copy text character by character

Image
  <! DOCTYPE html > < html lang = "en" > < head >     < meta charset = "UTF-8" >     < meta http-equiv = "X-UA-Compatible" content = "IE=edge" >     < meta name = "viewport" content = "width=device-width, initial-scale=1.0" >     < title > copy char by char </ title >     < script >         var ctr = 0 ;         function copyText ()         {             var arr = text1 . value ;             text2 . value = text2 . value + arr [ ctr ];             ctr ++;             if ( ctr > text1 . value . length )             {                 ctr = 0 ;                 text2 . value = "" ; ...

ftell() function in C Programming Language

Image
 //use of ftell() function in c ftell() function is used to return the position of the pointer in file. #include<stdio.h> void main() {     FILE *fptr;     int pos;     fptr=fopen("C:\\students\\batch8am-9am\\test.txt","w+");     if(fptr!=NULL)     {         fprintf(fptr,"hello");         pos=ftell(fptr);         printf("\n pointer location is %d",pos);         fprintf(fptr," vani");         pos=ftell(fptr);         printf("\n pointer location is %d",pos);         fclose(fptr);     } }//end of main Output of the program is :

Job Placement Training Package for B. Tech. Computer Science Students :

  During your B. Tech. Computer Science Stream, you have to study number of subjects. You must study all the subjects with full understanding during College time. We don't understand the importance of the subjects which are taught during the B. Tech.  But at the end of the degree we start to realize the importance of all the subjects. Some of the Technologies which are mostly required by the IT Industry to hire the B. Tech. Students are as following: >>Fundamentals of Programming Using C. >>Object Oriented Programming Concepts Using C++.  >>Programming Language JAVA. >>Understanding of Data Structures and Algorithms. >>Database Concepts and SQL. >>Web Technologies Client Side : HTML, CSS, Java Script >>Web Technologies Server Side: Python etc. >>Project using all the Technologies. >>English as communication language. At COMPUHELP We are providing the Job Placement Training for B. Tech Com...

How to Understand Programming and Learn Better ?

READ WITH IMAGINATION  OR NOT : There is nothing Possible without Programming in our real life. So you do programming everyday every moment of your day to day life. Programming is the way how you do your day to day jobs in efficient way. It must be efficient.  We do each and everything in our real life through brain programming. Think and imagine every word of your Teacher or any source of learning. Behave as compiler, translate your code as compiler on paper. Do not lie to your instructor at least during your learning times. Try to know the behavior of the machine you want to instruct or program. If you don't understand keep doing practice with attentive brain or with compiler brain. If Programming is your passion, that is very good, if not, make it passion, if not, quit.  Some times Passion serves needs of life and some times needs make your passion. Any how work or job must be your passion, or passion must be your work. If you are B. Tech. Student, be student during st...

Use of getch(),getche() and getchar() functions in C

Use of getch(),getche(),getchar() functions in C void main() { char ch; printf("Please enter a character:"); ch=getch(); printf("\n\nEntered character is %c\n\n",ch); printf("\n Please enter a character :"); ch=getche(); printf("\n\nEntered character is %c",ch); printf("\nPlease enter a character and press enter key :"); ch=getchar(); printf("\n Entered character is %c",ch); }//end of main function

Use of grids in web page to make partitions

Use of grids in web page to make partitions   < html > < head > < title >practice html webpage</ title > < style > .container3 {       background-color : brown ;         display : grid ;         grid-template-columns : 33 % 33 % 33 % ;         margin : 10 px ;         padding : 10 px ; } /*end of style block*/ .container2 { background-color : blueviolet ;         display : grid ;         grid-template-columns : 70 % 30 % ;         margin : 10 px ;         padding : 10 px ; } .container6 {         display : grid ;         grid-template-columns : auto auto auto ;         grid-gap : 5 px ; } .grid-items {         background-color : rgb ( 25 , 26 , 25 );         color : whitesmoke ...

How to Add Elements to the web page at run time?

How to Add Elements to the web page at run time?   < html >     < head >         < title >Testing</ title >         < script >             function addElement ()             {                 x = document. getElementById ( "mybody" );                 node = document. createElement ( "h1" );                 node.innerHTML = "this is new heading one" ;                 x. appendChild (node);                             }             var ctr = 0 ;             function addButton ()             {           ...