Basic concepts of OOP

The object oriented programming has been developed with a view to overcome the drawbacks of conventional programming approaches. The OOP approach is based on certain concepts that help it attain its goal of overcoming the drawbacks of shortcomings of conventional programming approaches. These general concepts of OOP are given below: Also Read: How to write and …

Basic concepts of OOP Read More »

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 produce the following design using *'s

#include<stdio.h> #include<conio.h> void main() { int i,j,k,n; clrscr(); //to clear the screen printf(“How many lines:”); scanf(“%d”,&n); n*=2; printf(“n”); for(i=1;i<n;i+=2) { for(j=n-1;j>i;j-=2) printf(” “); for(k=1;k<=i;++k) { if(i==n-1) printf(“*”); else if(k==1||k==i) printf(“*”); else printf(” “); } printf(“n”); } getch(); //to stop the screen; }

C program to produce the following design using *'s

#include<stdio.h> #include<conio.h> void main() { int i,j,k,n; clrscr(); //to clear the screen printf(“How many lines?”); scanf(“%d”,&n); n*=2; printf(“n”); for(i=0;i<n;i+=2) { for(j=1;j<i;j+=2) printf(” “); for(k=n-1;k>i;–k) printf(“*”); printf(“n”); } getch(); //to stop the screen }