JS Function programs collection
JS program to show the concept of arrow function
<script>
JS program using arrow function to return an object
()
tells JavaScript: “This is returning an expression.-->
()
tells JavaScript: “This is returning an expression.
DECLARE SUB SENDUP (S$)
E$ = "NPABSON"
Call SENDUP(E$)
End
Sub SENDUP (S$)
For i = 1 To Len(S$) Step 1
If i Mod 2 <> 0 Then
EE$ = EE$ + LCase$(Mid$(S$, i, 1))
Else
EE$ = EE$ + UCase$(Mid$(S$, i, 1))
End If
Next i
Print EE$
End Sub
'rem q9 A 2079 GP
declare sub perimeter(l,b)
declare function area(l,b)
Cls
Input "enter length and breadth"; l, b
Call perimeter(l, b)
Print "the area is"; area(l, b)
End
Sub perimeter (l, b)
p = 2 * (l + b)
Print "the perimeter is"; p
End Sub
Function area (l, b)
area = l * b
End Function
DECLARE SUB SERIES ( )
Cls
Call series
End
Sub series
A$ = "NEPAL"
B = 1
For I = Len(A$) To 1 Step -2
If B <> 3 Then
Print Mid$(A$, B, I)
Else
Print Mid$(A$, 1, I)
End If
B = B + 1
Next I
End Sub
'q9(b) triton SEE model set set II
Open "record.dat" For Input As #11
Cls
c = 0
While Not EOF(11)
Input #11, sno, name$, address$, tel, email$
If LCase$(Right$(email$, 9)) = "yahoo.com" Then
c = c + 1
Print name$, address$, email$
End If
Wend
Print "total records having email is="; c
Close #11
End
#include <stdio.h>
#include<string.h>
void main ()
{
char string[] = {'c', 'o', 'm', 'p', 'u', 't', 'e', 'r'};
printf("%s", string);
getch();
}
output:-
//WAP to reverse a string using(strrev()) function.Pass string as parameter and return its reverse
#include <stdio.h>
#include<string.h>
#include<conio.h>
char *stringrev(char string[]);
/* function named stringrev() that accepts a string and returns
a char(i.e. pointer to character/string)
int main()
{
char name[100];//string declaration
printf("enter string\n");
scanf("%[^\n]",name);
printf("reverse=%s\n",stringrev(name));//prints the name
getch();
return 0;
}
char *stringrev(char string[])
{
strrev(string);
return string;
}