Skip to main content

Posts

Showing posts with the label C Program

C Program to print "hello World" without semicolon

 C Program to print "hello World" without semicolon Do Check My Video : Code: /********** C Program to print "hello" without semicolon **********/ #include <stdio.h> int main() { if(printf("Hello World\n")){ } switch(printf("Hello World\n")){ } while(!printf("Hello World")){ } return 0; } o/p: Hello World Hello World Hello World

Perfect Number Program in C

 Perfect Number Program in C Do Check My Video For Perfect Number:   Perfect Number :  In mathematics, a perfect number is a positive integer that is equal to the sum of its positive divisors, excluding the number itself. ex : 6 = 1,2,3 <  6    1+2+3 =6  ex: 5 : 1  sum = 1 !=5  5 is not perfect number Perfect Numbers examples : 6,28,496,8128 Program to check given number is perfect or not: #include<stdio.h> int main(){ int n; printf("Enter the number: "); scanf("%d",&n); int sum = 0,i; for(i=1;i<n;i++){ if(n%i==0){ sum = sum + i; } } if(sum == n){ printf("%d is a perfect Number",n); }else{ printf("%d is not perfect Number",n); } return 0; }