/* gcc -ansi -Wall -Wextra -pedantic -s -static 0.c -o 0 */
#include <stdio.h>
int main ( )
{
int n = 5 , factorial = 1 ;
while ( n != 0 )
{
factorial *= n ;
n -- ;
}
printf ( "%i\n" , factorial ) ;
return 0;
}
Use the following function:
unsigned fact (unsigned num) { return num < 2 ? 1 : num * fact (num-1); }
Note that if sizeof (unsigned) is only 4 (bytes), this function can only handle factorials up to fact (12). However it will easily handle fact (4), returning 4*3*2*1=24.
The non-recursive solution is as follows:
unsigned fact (unsigned num) {
unsigned f = 1;
while (1<num) f *= num--;
return f;
}
Using while loop, write a program which calculates the product of digits from 1 to 5 and also show these no's vertically.
Write a program which takes the temperature in farhenheight.the program should display the farhenheight temperature as well as centigrade. C= (f-32)*5/9
Perform encryption on the following PT using RSA and find the CT p = 3; q = 11; M = 5
12345 1234 123 12 1
#include#includevoid main(){ int a,i;printf("\nThe Multiplication table of 5 is:\n");for(i=1;i
nr\m;laeoh9y0m g.qthnedxc In fortran: do i=1,5 write(6,*)i enddo stop end This program will write the numbers 1 to 5 on the screen.
There is no such thing; you seem to have misunderstood something.Any real number can be regarded as a complex number with zero imaginary part, eg.: 5 = 5+0i
Using while loop, write a program which calculates the product of digits from 1 to 5 and also show these no's vertically.
Write a program which takes the temperature in farhenheight.the program should display the farhenheight temperature as well as centigrade. C= (f-32)*5/9
int i=10, j=5, k; k=i*j; // k = 10 * 5 = 50
Write a program in C for showing working of different logical operator in C.Your program should guide users with proper message/menu on the console. (5 Marks)
To find the ratio for 5 over 8, you simply write it as a fraction: 5/8.
It would depend on the program you are using and weather or not it is allowable.
Perform encryption on the following PT using RSA and find the CT p = 3; q = 11; M = 5
12345 1234 123 12 1
5 x 5 x 5 x 5 = 625
Use a text-editor.