C program to find the sum of series 1/2+4/5+7/8+……

#include<stdio.h> #include<conio.h> void main() { int i,n; clrscr(); float sum=0,x,a=1; printf(“1/2+4/5+7/8+……”); printf(“nnHow many terms(ex: 1,2,3…n)?”); scanf(“%d”,&n); for(i=0;i<n;++i) { x=a/(a+1); sum+=x; a+=3; } printf(“nSum=%f”,sum); getch(); }

C program to swap two numbers without using temporary variable

#include<stdio.h> #include<conio.h> void main() { int x,y; clrscr(); printf(“Enter value of X: “); scanf(“%d”,&x); printf(“Enter value of y: “); scanf(“%d”,&y); if(x>y) { y=x-y; x=x-y; y=x+y; } else if(y>x) { x=y-x; y=y-x; x=y+x; } printf(“nx=%d”,x); printf(“ny=%d”,y); getch(); }

Convert Decimal to Binary in C

Here you will get program to convert decimal to binary in C. We can convert a decimal number into binary by repeatedly dividing it by 2 and storing the remainder somewhere. Now display the remainders in reverse order. Also Read: Convert Binary to Decimal in C Convert Decimal to Binary in C #include<stdio.h> int main() { …

Convert Decimal to Binary in C Read More »

C++ Program to Print Truth Table of XY+Z

Here you will get C++ program to print truth table of XY+Z. #include<iostream> using namespace std; int main() { int x,y,z; cout<<“X\tY\tZ\tXY+Z”; for(x=0;x<=1;++x) for(y=0;y<=1;++y) for(z=0;z<=1;++z) { if(x*y+z==2) cout<<“\n\n”<<x<<“\t”<<y<<“\t”<<z<<“\t1”; else cout<<“\n\n”<<x<<“\t”<<y<<“\t”<<z<<“\t”<<x*y+z; } return 0; }   Output X Y Z XY+Z 0 0 0 0 0 0 1 1 0 1 0 0 0 1 1 …

C++ Program to Print Truth Table of XY+Z Read More »

C++ Program to Add Two Numbers

Here you will get C++ program to add two numbers. The program will ask user to enter two numbers and then calculate their sum. #include<iostream> using namespace std; int main() { int x,y,sum; cout<<“Enter first no: “; cin>>x; cout<<“Enter second no: “; cin>>y; sum=x+y; cout<<“\nSum = “<<sum; return 0; } Output Enter first no: 4 …

C++ Program to Add Two Numbers Read More »