Write a program to split all the digit from a given integer input and make sum of all digits. Sample Input: 13245 Sample Output: The digits are: 1 3 2 4 5 Sum: 6
Write a program in c to find the factorial of a number #include <stdio.h> int main(){ int i=1,f=1,num; printf( "Enter a number: " ); scanf( "%d" ,&num); while (i<=num){ f=f*i; i++; } printf( "Factorial of %d is: %d" ,num,f); return 0; } Sample output: Enter a number: 5 Factorial of 5 is: 120 Do you know what is zero (0) Factorial ?
visit the problem source : #include <stdio.h> #include<conio.h> int main () { int n,i,s,p,j; clrscr(); printf("Enter your range(n) :"); scanf("%d",&n); p=1; for (i=1;i<=n;i++) { s=0; for (j=1;j<=i;j++) { s=s+i; } p*=s; } printf("\n The value of p is =%d",p); getch(); return 0; } sample input/output: input : 4 output : The value of p is =576
This prints out all acsii values void main () { int i ; i = 0 ; do { printf ( "%d %c \n" , i , i ); i ++; } while ( i <= 255 ); } This prints out the acsii value for a given character: void main () { int e ; char ch ; clrscr (); printf ( "\n Enter a character : " ); scanf ( "%c" , ch ); e = ch ; printf ( "\n The ASCII value of the character is : %d" , e ); getch (); }
#include <stdio.h> #include<conio.h> int main() { int i; float fArray[4]; clrscr(); for (i = 0; i < 4; i++) { printf("Please enter a float: "); scanf("%f", fArray[i]); } getch(); return 0; } output: