Note 1
Take Note:

Take a note while surfing.

Note With Ink

Give your Note a Colorful Tag.

Easy to Access

Stay on same information and in Sync wherever you are.

Note 2
Take Note:

Organize your information,It may take Shape.

Easy to Access

Easy to pull up your content from anywhere anytime.

Note 3
Take Note:

Don't Let information to miss,Because it take shape

Note With Ink

Simple an Easy Way to take a note.

Easy to Access

Get the same in next visit.

Question :: 21
Write an efficient program to convert from binary to decimal number

Input : NA

Output : NA

|  Bitwise Operator | | | |  Fresher
``` ```
#include<iostream>
using namespace std;
int main()
{
long bin, dec = 0, rem, num, base = 1;
cout << "Enter the binary number(1s and 0s) : ";
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;
}
``````

Tags:No Tags on this question yet!

Question :: 22
Write an efficient program to reverse the given binary number

Input : NA

Output : NA

|  Bitwise Operator | | | |  Fresher
``` ```
#include <stdio.h>
#include<iostream>
using namespace std;
unsigned int reverseBits(unsigned int num)
{
unsigned int NO_OF_BITS = sizeof(num) * 8;
unsigned int reverse_num = 0, i, temp;
for (i = 0; i < NO_OF_BITS; i++)
{
temp = (num & (1 << i));
if(temp)
reverse_num |= (1 << ((NO_OF_BITS - 1) - i));
}
return reverse_num;
}
/* Driver function to test above function */
int main()
{
unsigned int x = 2;
printf("%u", reverseBits(x));
getchar();
}

``````

Tags:No Tags on this question yet!

Question :: 23
Write an efficient program to implement the strlen, strcmp, strcpy, strncmp function.

Input : NA

Output : NA

|  Strings | | | |  Fresher
``` ```
#include <stdio.h>
#include<iostream>
using namespace std;
int main()
{
int bin_no1 = "0110111";
int bin_no2= "01110111";
int len=3;
int strlength1= strlen (bin_no1)   ;
int strlength2= strlen (bin_no2)   ;
cout<<" 1st Binary no is  : " << bin_no1<<"\t and its length is :"<<\$strlength1<<"\n";
cout<<" 2nd Binary no is  : " <<bin_no2<< "\t and its length is :"<<\$strlength2<<"\n";
if (strcmp(bin_no1, bin_no2) !== 0)
{
cout<<bin_no1 <<"is not equal to"<< bin_no2 <<"in a binary comparison";
}
else {
cout<<"bin_no1<<" is equal to"<<bin_no2 <<"in a binary comparison";
}
if (strncmp(bin_no1, bin_no2 ,len) !== 0)     {
cout<<bin_no1 <<"is not equal to"<< bin_no2 <<"in a binary comparison";
}
else {
cout<<"bin_no1<<" is equal to"<<bin_no2 <<"in a binary comparison";
}
getch();
return 0;
}
``````

Tags:No Tags on this question yet!

Question :: 24
Write an efficient program to find the substring in a main string.

Input : NA

Output : NA

|  Strings | | | |  Fresher
``` ```
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int i,j,temp;
char str[100]={"This is a pattern matching"};
char substr[20]={"pattern"};
for(i=0;str[i]!='\0';i++)
{
j=0;
if(str[i]==substr[j])
{
temp=i+1;
while(str[i]==substr[j])
{
i++;
j++;
}
if(substr[j]=='\0')
{
cout<<"The substring is present in given string at position "<<temp<<"\n";
exit(0);
}
else
{
i=temp;
temp=0;
}
}
}

if(temp==0)
cout<<"The substring is not present in given string\n";

return 0;
}
``````

Tags:No Tags on this question yet!

Question :: 25
Write an efficient program to reverse the string, words in a given sentence.

Input : NA

Output : NA

|  Strings | | | |  Fresher
``` ```
#include <stdio.h>#include <string.h>#include<iostream>using namespace std;void main(){    int i, j = 0, k = 0, x, len;    char str[100], str1[10][20], temp;     cout<<"enter the string :";    cin>>str;/* reads into 2d character array */    for (i = 0;str[i] != '\0'; i++)    {        if (str[i] == ' ')        {            str1[k][j]='\0';            k++;            j=0;        }        else        {            str1[k][j]=str[i];            j++;        }    }    str1[k][j] = '\0'; /* reverses each word of a given string */    for (i = 0;i <= k;i++)    {        len = strlen(str1[i]);        for (j = 0, x = len - 1;j < x;j++,x--)        {            temp = str1[i][j];            str1[i][j] = str1[i][x];            str1[i][x] = temp;        }    }    for (i = 0;i <= k;i++)    {        cout<<str1[i];    }}
``````

Tags:No Tags on this question yet!

Question :: 26
Write an efficient program to implemnt the atoi function.

Input : NA

Output : NA

|  Strings | | | |  Fresher
``` ```
int myAtoi(char *str){    int res = 0; /* Initialize result*/      /* Iterate through all characters of input string and update result*/    for (int i = 0; str[i] != '\0'; ++i)        res = res*10 + str[i] - '0';      /* return result.*/    return res;}  /* Driver program to test above function*/int main(){    char str[] = "89789";    int val = myAtoi(str);  cout<< val;    return 0;}
``````

Tags:No Tags on this question yet!

Question :: 27
Write an efficient program to implement itoa function.

Input : NA

Output : NA

|  Strings | | | |  Fresher
``` ```
#include <iostream>
using namespace std;
/* A utility function to reverse a string */
void reverse(char str[], int length)
{
int start = 0;
int end = length -1;
while (start < end)
{
swap(*(str+start), *(str+end));
start++;
end--;
}
}
/* Implementation of itoa()*/
char* itoa(int num, char* str, int base)
{
int i = 0;
bool isNegative = false;
/* Handle 0 explicitely, otherwise empty string is printed for 0 */
if (num == 0)
{
str[i++] = '0';
str[i] = '\0';
return str;
}
/* In standard itoa(), negative numbers are handled only with base 10. Otherwise numbers are considered unsigned.*/
if (num < 0 && base == 10)
{
isNegative = true;
num = -num;
}

// Process individual digits
while (num != 0)
{
int rem = num % base;
str[i++] = (rem > 9)? (rem-10) + 'a' : rem + '0';
num = num/base;
}

/* If number is negative, append '-'*/
if (isNegative)
str[i++] = '-';

str[i] = '\0'; // Append string terminator
/* Reverse the string*/
reverse(str, i);
return str;
}
/* Driver program to test implementation of itoa()*/
int main()
{
char str[100];
cout << "Base:10 " << itoa(1567, str, 10) << endl;
cout << "Base:10 " << itoa(-1567, str, 10) << endl;
cout << "Base:2 " << itoa(1567, str, 2) << endl;
cout << "Base:8 " << itoa(1567, str, 8) << endl;
cout << "Base:16 " << itoa(1567, str, 16) << endl;
return 0;
}

``````

Tags:No Tags on this question yet!

Question :: 28
Read a string from terminal.Create a linked list to store each character in a linked list. Each node of the linked list must hold character, position in the string and count of occurrences. Write a function to remove the duplicate character in the string. Display the linked list before and after removal of duplicate characters.

Input : NA

Output : NA

|  Linked List | | | |  Fresher
` `No Discussion on this question yet!``

Tags:No Tags on this question yet!

Question :: 29
Write an efficient program to detect and remove loop in a linked list

Input : NA

Output : NA

|  Linked List | | | |  Fresher
``` ```
``````

Tags:No Tags on this question yet!

Question :: 30
Write an efficient program to find the middle element in the list

Input : NA

Output : NA

|  Linked List | | | |  Fresher
``` ```