Begin read a,b if a>b display a is greater else display b is greater end
Function is_prime(ByVal num As Integer) As Boolean If num < 0 Then num = num * -1 If num < 2 Then Return False If num Mod 2 = 0 Then Return num = 2 Dim max As Integer = Math.Sqrt(num) For div As Integer = 3 To max Step 2 If num Mod div = 0 Then Return False Next Return True End Function Sub Main() For num As Integer = 0 To 100 If is_prime(num) Then Console.Write(num) Console.WriteLine(" is prime") End If Next End Sub
The scanf() function is a commonly used function to input information during the execution of a program. scanf() function has its prototype in the stdio.h header file. To accept and display a number: int num; printf("Enter a number: "); scanf("%d",&num); printf("You entered %d",num); To accept and display a character, replace %d with %c and make num a character variable [char]. Plus: gets, fgets, read, fread, getchar, getc, fgetc, getch...
You can use the following C program to display "1" if a user enters any non-zero number, and "0" if the entered number is zero: #include <stdio.h> int main() { int num; printf("Enter a number: "); scanf("%d", &num); if (num != 0) { printf("1\n"); } else { printf("0\n"); } return 0; } This program reads an integer from the user and checks if it is non-zero or zero, then prints the corresponding output.
#include#includebool is_prime(unsigned num) {unsigned max, factor;if (num
Begin read a,b if a>b display a is greater else display b is greater end
Function is_prime(ByVal num As Integer) As Boolean If num < 0 Then num = num * -1 If num < 2 Then Return False If num Mod 2 = 0 Then Return num = 2 Dim max As Integer = Math.Sqrt(num) For div As Integer = 3 To max Step 2 If num Mod div = 0 Then Return False Next Return True End Function Sub Main() For num As Integer = 0 To 100 If is_prime(num) Then Console.Write(num) Console.WriteLine(" is prime") End If Next End Sub
#include<iostream> int main() { for(int num=2; num<=50; i+=2) std::cout << num << std::endl; return(0); }
num lock, caps lock, scroll lock
loop i from 0 to num check if num mod i equals 0breakelsesum = sum + numend the loopprint the sum
unsigned binary_to_gray (unsigned num) { return num ^ (num >> 1); } unsigned gray_to_binary (unsigned num) { /* note: assumes num is no more than 32-bits in length */ num ^= (num >> 16); num ^= (num >> 8); num ^= (num >> 4); num ^= (num >> 2); num ^= (num >> 1); return num ; }
The scanf() function is a commonly used function to input information during the execution of a program. scanf() function has its prototype in the stdio.h header file. To accept and display a number: int num; printf("Enter a number: "); scanf("%d",&num); printf("You entered %d",num); To accept and display a character, replace %d with %c and make num a character variable [char]. Plus: gets, fgets, read, fread, getchar, getc, fgetc, getch...
You can use the following C program to display "1" if a user enters any non-zero number, and "0" if the entered number is zero: #include <stdio.h> int main() { int num; printf("Enter a number: "); scanf("%d", &num); if (num != 0) { printf("1\n"); } else { printf("0\n"); } return 0; } This program reads an integer from the user and checks if it is non-zero or zero, then prints the corresponding output.
num num num
sum=0 i=1 echo "Enter any number " read num while [ $i -le 10 ] do sum=`expr $num \* $i` i=`expr $i + 1` echo "Table of a number is " $sum done
In simple Python code: def convertToAngle(num): while True: if num < 0: num = 360 - num elif num > 360: num -= 360 else: break return num
#include#includebool is_prime(unsigned num) {unsigned max, factor;if (num