Posts

Showing posts from August, 2016

Program for Decimal to Binary Conversion

www.programmingcalculator.com https://nikhilnihal.github.io/programmingcalculator/index.html C++ Program for Decimal to Binary Conversion #include<bits/stdc++.h> using namespace std; int main() {     long dec,rem,i=1,sum=0,binary=0;     cout<<"Enter the decimal to be converted:";     cin>>dec;     while(dec!=0)     {       rem=dec%2;       dec/=2;       binary+=rem*i;       i*=10;     }     cout<<"The binary of the given number is:"<<binary<<endl;     return 0; }

Program for Binary to Decimal Conversion

www.programmingcalculator.com https://nikhilnihal.github.io/programmingcalculator/index.html C++ Program to Convert Binary To Decimal #include<bits/stdc++.h> using namespace std; int main() {     long bin, dec = 0, rem, num, base = 1;     cout << "Enter the binary number";     cin >> num;     bin = num;     while (num > 0)     {         rem = num % 10;         dec = dec + rem * base;         base = base * 2;         num = num / 10;     }     cout << "The decimal equivalent of " << bin << " : " << dec << endl;     return 0; }

Ratio of Two Numbers

www.programmingcalculator.com https://nikhilnihal.github.io/programmingcalculator/index.html C++ PROGRAM TO FIND RATIO OF TWO NUMBERS #include<bits/stdc++.h> using namespace std; int main() {     int first_number, second_number,ans,t,gcd;     cin>>first_number>>second_number;     int a=first_number;     int b=second_number;     while (b != 0) {      t = b;      b = a % b;      a = t;     }     gcd = a;     printf("%d/%d",first_number/gcd,second_number/gcd);     return 0; }

Power Finding Program

www.programmingcalculator.com https://nikhilnihal.github.io/programmingcalculator/index.html C++ PROGRAM FOR FINDING POWER #include <bits/stdc++.h> using namespace std ; int main () { int exp ; float base , power = 1 ; cin >> base >> exp ; while ( exp != 0 ) { power *= base ; -- exp ; } cout << "Result = " << power ; return 0 ; }

L.C.M and H.C.F Program

www.programmingcalculator.com https://nikhilnihal.github.io/programmingcalculator/index.html C++  PROGRAM  FOR  FINDING  H.C.F.  &  L.C.M. #include<bits/stdc++.h>   int main ( ) { int a , b , x , y , t , gcd , lcm ;   cin>>a>>b;   a = x ; b = y ;   while ( b != 0 ) { t = b ; b = a % b ; a = t ; }   gcd = a ; lcm = ( x * y ) / gcd ;   cout<<gcd<<endl; cout<<hcf<<endl;   return 0 ; }

Logical XOR Program

www.programmingcalculator.com https://nikhilnihal.github.io/programmingcalculator/index.html C++ Program for Logical XOR of two Decimal Numbers #include<bits/stdc++.h> using namespace std; int main() {     int first_number, second_number,ans;     cin>>first_number>>second_number;     ans=first_number^second_number;     cout<<ans<<endl;     return 0; }

Logical OR Program

www.programmingcalculator.com https://nikhilnihal.github.io/programmingcalculator/index.html C++ Program for Logical OR of two Decimal Numbers #include<bits/stdc++.h> using namespace std; int main() {     int first_number, second_number,ans;     cin>>first_number>>second_number;     ans=first_number|second_number;     cout<<ans<<endl;     return 0; }

Logical AND Program

www.programmingcalculator.com C++ Program for Logical  AND of Two Decimal Numbers #include<bits/stdc++.h> using namespace std; int main() {     int first_number, second_number,ans;     cin>>first_number>>second_number;     ans=first_number&second_number;     cout<<ans<<endl;     return 0; }

Barracuda networks (A Bangalore's Startup) written Round Programming Questions

1) C program to copy one file to another. #include<bits/stdc++.h> using namespace std; int main() {     char ch,src[20],tgt[20];     FILE *s,*t;     gets(src);     s=fopen(src,"r");     if(s==NULL)     {         printf("press any key to exit\n");         exit(EXIT_FAILURE);     }     gets(tgt);     t=fopen(tgt,"w");     if(t==NULL)     {         printf("press any key to exit\n");         exit(EXIT_FAILURE);     }     while(( ch=fgetc(s))!=EOF)         fputc(ch,t);     return 0; } - ---------------------------------------------------------------------------------------------------------------------- 2 ) use function pointer to add , sub and multiply #include<bits/stdc++.h> using namespace std; ...

DMX technologies (A Bangalore's Startup) written Round Programming Questions

1) Spiral Matrix Printing     For example : if given n=2 , then output is   3 2                                                                        0  1                        if given n=3 , then output is   4  3  2                                                                       5  0  1                                                                   ...