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 Print Multiplication Table of Given Number

Here you will get C program to print multiplication table of given number. Below program will ask user to enter a number then display its table. #include<stdio.h> int main() { int i,n; printf(“Enter any number:”); scanf(“%d”,&n); printf(“Table of %d is:\n”, n); for(i=1;i<=10;++i) printf(“\n%d*%d=%d”,n,i,n*i); return 0; }   Output Enter any number:6 Table of 6 is: …

C Program to Print Multiplication Table of Given Number Read More »

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 }