Computer Science » C Program » Rectangle using Line and Special Symbols Program : [php]#include<stdio.h> int main() { int i, j; for (i = 0; i < 10; i++) { printf("n"); for (j = 0; j < 10; j++) { if (i == 0 || i == 9 || j == 0 || j == 9) printf("▲"); else printf("-"); } } return (0); }[/php] Output : [php]▲▲▲▲▲▲▲▲▲▲ ▲--------▲ ▲--------▲ ▲--------▲ ▲--------▲ ▲--------▲ ▲--------▲ ▲--------▲ ▲--------▲ ▲▲▲▲▲▲▲▲▲▲[/php]
Computer Science » C Program » Find Factorial of a Number Program : [php]#include <stdio.h> int main() { int i, fact = 1, num; printf("Enter the number : "); scanf("%d", &num); if (num <= 0) fact = 1; else { for (i = 1; i <= num; i++) { fact = fact * i; } } printf("nFactorial of %d is : %5d", num, fact); }[/php] Output : [php]Enter the number : 5 Factorial of 5 is : 120[/php]
Computer Science » C Program » Check if Number is Odd or Even Program : [php]#include<stdio.h> int main() { int n; printf("nEnter a number : "); scanf("%d",&n); if ( n%2 == 0 ) printf("n%d is an even number.", n); else printf("n%d is an odd number.", n); return 0; }[/php] Output 1: [php]Enter an number : 122 122 is an even number.[/php] Output 2: [php]Enter an number : 123 123 is an odd number.[/php]