Decimal to octal conversion

The following program takes a decimal number as an input and prints its octal equivalent. This program is implemented using c. Code: #include<stdio.h>int main(){ int n,a[100],i,j; printf(“Enter a decimal number : “); scanf(“%d”,&n); for (i=0;n!=0;i++) { a[i]=n%8; n=n/8; } printf(“The octal equivalent is : “); for (j=i-1;j>=0;j–) { printf(“%d”,a[j]); } return 0;} Output:

Check whether a number is perfect or not

The below program takes a integer as input and checks whether the input is a perfect number or not. Perfect number is a positive integer which is the sum of its proper positive divisor which means the sum of its positive divisors excluding the number itself. Ex: 6 is a perfect number as it is sum of proper positive number. 6=1+2+3 28 is a perfect number as it is sum of proper positive number. 28=1+2+4+7+14 Code: #include<iostream>using namespace std;int main(){ int n,r=0; cout<<“Enter a number : “; cin>>n; for(int i=1;i<n;i++)…

Count number of letters and words present in string

The following program takes a string as input and prints number of letters and number of words present in the string. The following code is implemented using  c. Code: #include<stdio.h>#include<string.h>int main(){ int c=0,c1=0,i; char str[30]; printf(“Enter a sentence : n”); gets(str); for(i=0;str[i]!=”;i++) { c++; if(str[i]==’ ‘) c1++; } printf(“nNumber of letters present : %d”,c); printf(“nNumber of words present : %d”,c1+1); return 0;} Output:

Hackerrank Python Triangle Quest Solution

This is the solution for the question at hackerrank, python triangle quest solution. In the question you have to display the output using just a single for loop and a print statement. If used more then 2 lines of code you will not be awarded any score. So here is that simple 2 line of code using which u can solve triangle quest which is a moderate(difficult) level question. Screenshot/ Outputs The complete 2 line code for i in range(1,input()): print ((10**i – 1)/ 9)*i If this post helped you,…

Binary Search Iterative method in python

This is an iterative method for the binary search algorithm. It takes a list as an input and another variable which is the data to be searched, and then passes them to the bin() function. And in bin() there is a single while loop. Screenshots/ Output : The Code def bin(x,y): l=0; h=len(x)-1; while(l<=h): mid=(l+h)/2 if(x[mid]<y): l=mid+1 elif(x[mid]>y): h=mid-1 elif(x[mid]==y): print “found ” break; else: print “Not Found “x=input()y=input()bin(x,y);

Create a Lightweight Blogging System Using PHP and MYSQL

This post will help you to create your very own lightweight blogging system. This system is completely created by using PHP and mysql. This system consists of 4 files namely admin.php, index.php, art.php and .htaccess. We will go through each files deeply. This time on we have used automatic setup system which will automatically create database and tables. In this system we have created a database article and table article. Lets see the screens of various pages: The homepage of the Blogging system showing the titles of the posts. When…

Create a simple chatroom system in php without databases

In this post, you will be guided to create a simple chatroom system in php without any databases. This system will create a folder for each chatroom and will store data in a simple .txt file, which is later accessed from the server side to display the conversations in the chatroom. This chatroom is flexible and light weight, it automatically reloads itself in 10 seconds so that new information is fetched correctly. The complete system is based on just a single php file in which file handling is used to…

Create a Simple Color Picker Android App [Seekbar Support]

This post will let you create a simple Color picker android application which will return the HEX code from the values set by R,G, and B labeled seekbars. In this application you can not only get the HEX value of the color generated but you can also set the color as the application background. This app is created by 3 seekbars and 1 EditText and 2 buttons. The value of the seekbars are extracted form the getProgress() method. and the obtained values from R,G, and B are converted to hex using toHexString()…