max= a>b? a: b;
num=32767 MsgBox(len(num))
#include #include void main() { int rev num=0; while(num>0) { rev num=rev num*10+num%10; num=num%10; } return rev_num; } int main(); { int num=4562; printf("reverse of number is%d",reverse digit(num)); getch(); return o; }
Using for loop we can find sum of digits of a number. Inside the loop just perform Logic Expression 1) rem=num%10. {To find the unit place no. using remainder functon} 2) sum = sum+rem {to find the addition ie output} 3) num=num/10 {to eliminate the added digit} Just repeat these steps in the loop.
report zbharath. data:num type i value 5, fac type i value 0. perform fact using num changing fac. write:/ 'factorial of',num,'is',fac. form fact. using value(f-num) type i. changing f-fact type i. f-fact=1. while f-num ge 1. f-fact=f-fact*f-num. f-num=f-num-1. endwhile. endform.
#include <iostream> using std::cout; using std::cin; using std::endl; int main() { int max; int num; for (int counter = 0; counter<15; counter++) { cout <<"Enter a number: "; cin >> max; cout << "Enter another number: "; cin >> num; if (num > max) num = max; cout << "The largest number is " <<max; } return 0; }
num = 0 For eachRepeat = 1 To 5 num = num + 5 Next MsgBox(num)
You need two utility functions. The first determines if a given number is prime or not. The second finds the next prime after a given number. The following function can be used to determine if a given integer is prime: bool is_prime (const unsigned num) { if (num<2) return false; if (0==(num%2)) return num==2; unsigned max_factor = (unsigned) sqrt ((double) num) + 1; unsigned factor; for (factor=3; factor<max_factor; ++factor) if (0==(num%factor)) return false; return true; } The following function can be used to determine the next prime after the given integer: unsigned next_prime (unsigned num) { while (!is_prime (++num)); return num; } Now you can print a series of primes using the following: int main (void) { unsigned num=1; while (num<10000) { num = next_prime (num); printf ("%d is prime\n", num); } return 0; }
To find the biggest number in an array without using the max function, you can initialize a variable to hold the largest number, typically starting with the first element of the array. Then, iterate through the array using a loop, and for each element, compare it with the current largest number. If the current element is greater, update the largest number. Finally, after the loop, the variable will contain the largest number in the array. Here’s a simple example: arr = [3, 5, 2, 9, 1] largest = arr[0] for num in arr: if num > largest: largest = num print(largest) # Output: 9
int cube=1,num,i; for(i=1;i<=3;i++){ cube*=num; }
//by rsravan12 #include<stdio.h> #include<conio.h> void main() { long int num,sum,k,temp ; clrscr(); printf("\nenter num= "); scanf("%d",&num); sum=0;num=temp; while(temp>0) { temp=temp%10; sum=sum+k*k*k; temp=temp/10; } if(num==sum) { printf("\n%d is armstrong",num); } else { printf("\n%d is not a armstrong",num); } getch(); } //hyderabad
main() { int num=0xABCD; printf("%x\n",num); int rev=0x0; int digit=0x0; while(num!=0x0) { digit=num%0x10; rev = rev*0x10 +digit; num=num/0x10; } printf("%x\n",rev); }
you call this num 9225267751 and they will schedual a flight to take you out to L.A to audition