Loops

C program to print the truth table for XY+Z

#include<stdio.h> #include<conio.h> void main() { int x,y,z; clrscr(); //to clear the screen printf(“XtYtZtXY+Z”); for(x=0;x<=1;++x) for(y=0;y<=1;++y) for(z=0;z<=1;++z) { if(x*y+z==2) printf(“nn%dt%dt%dt1”,x,y,z); else printf(“nn%dt%dt%dt%d”,x,y,z,x*y+z); } getch(); //to stop the screen }

C program to generate divisors of an integer

#include<stdio.h> #include<conio.h> void main() { int i,n; clrscr();  //to clear the screen printf(“Enter any number:”); scanf(“%d”,&n); printf(“nDivisors of %d are”,n); for(i=1;i<n/2;++i) if(n%i==0) printf(” %d”,i); getch();  //to stop the screen }

Program for Number Palindrome in C

Here you will get program for number palindrome in C. A number is palindrome if it is equal to its reverse. For example 121, 111, 1331 are palindrome numbers. Program for Number Palindrome in C   Output Enter any number:12321 The given number is palindrome

Program for Prime Number in C

Here you will get program for prime number in C. A number that is only divisible by 1 or itself is called prime number. For example, 17 is prime, 6 is not prime, etc. Program for Prime Number in C   Output Enter any number:15 The given number is not prime