Skip to main content

Posts

Showing posts with the label c program to find factorial of a given no.

C Program To Find Prime Number Between 1 And 100.

34) Sample C Program to print prime numbers between 1 to 100. # include <stdio.h> # include <conio.h> main( ) { int n, i, check; clrscr(); for(i = 1; i <= 100; i++) { check = 1; for(n = 2; n <= i / 2; n++) if(i % n == 0) { check = 0; break; } if(check == 1) printf("\n %d is a prime", i); else printf("\n %d is not a prime", i); } getch( ); } 35) Sample C Program to accept two numbers and print sum of two numbers by using functions. # include <stdio.h> # include <conio.h> main( ) { int a, b, c; clrscr(); printf("Enter the value for a:") scanf("%d",&a); printf("Enter the value for b:") scanf("%d",&b); c = add(a, b); printf("Sum of two numbers is %d",c); getch( ); } int add(int x, int y) { int z; z = x + y; return z; } 36) Sample C Program to accept a number and find factorial of given number. # include <stdio.h> # incl...