#include<stdio.h> #include<conio.h> int fact(int); int main() { int x,n; printf(" Enter the Number to Find Factorial :"); scanf("%d",&n); x=fact(n); printf(" Factorial of %d is %d",n,x); return 0; } int fact(int n) { if(n==0) return(1); return(n*fact(n-1)); } Output:- Enter the Number to Find Factorial :3 Factorial of 3 is 6
#include <stdio.h> #include<conio.h> int main() { int age; // variable declaration printf("Enter your age"); scanf("%d",&age); // taking user input for age variable (age>=18)? (printf("eligible for voting")) : (printf("not eligible for voting")); // conditional operator return 0; } Output:- Enter your age13 not eligible for voting Enter your age19 eligible for voting
Comments
Post a Comment