The JavaScript language Here we learn JavaScript, starting from scratch and go on to advanced concepts like OOP. We concentrate on the language itself here, with the minimum of environment-specific notes
JavaScript syntax // How to create variables: var x; let y; // How to use variables: x = 5 ; y = 6 ; let z = x + y; The two most important syntax rules for fixed values are: 1. Numbers are written with or without decimals: 10.50 1001 2. Strings are text, written within double or single quotes: example: "John Doe" 'John Doe' JavaScript Variables In a programming language, variables are used to store data values. JavaScript uses the keywords var , let and const to declare variables. An equal sign is used to assign values to variables. In this example, x is defined as a variable. Then, x is assigned (given) the value 6: example : let x; x = 6 ; JavaScript Operators JavaScript uses arithmetic operators ( + - * / ) to compute values: example : JavaScript uses an assignment operator ( = ) to assign values to variables: example : let x, y;...
C program to print Pascal triangle 1 1 1 1 2 1 1 3 3 1 #include <stdio.h> long factorial ( int ) ; int main ( ) { int i , n , c ; printf ( "Enter the number of rows you wish to see in pascal triangle \n " ) ; scanf ( "%d" ,& n ) ; for ( i = 0 ; i < n ; i ++ ) { for ( c = 0 ; c <= ( n - i - 2 ) ; c ++ ) printf ( " " ) ; for ( c = 0 ; c <= i ; c ++ ) printf ( "%ld " , factorial ( i ) / ( factorial ( c ) * factorial ( i - c ) ) ) ; printf ( " \n " ) ; } return 0 ; } long factorial ( int n ) { int c ; long result = 1 ; for ( c = 1 ; c <= n ; c ++ ) result = result * c ; return result ; }
Comments
Post a Comment