1]
Write a program to sort the array on the basis of data in the 3rd nibble.
If the data in the third nibble of any element is larger then that element should
be at the last.
Example: int a[5]={15<<8,15<<12,256,128,512};
Output: a[5]={15<<12,128,256,512,15<<8};
Note: Use the following function prototype.
Void sort(int *,int *);
Print the result in main()
2]
Write a program to add each element of the array until the sum not become
single digit. Then replace that element with the single digit sum.
Example: int a[5]={12345,2589,256,128,512};
Output: a[5]={6,6,4,2,8};
Note: Use the following function prototype.
Void add(int *,int *);
Print the result in main()
3]
Write a program to swap nibbles in each byte of each array element.
Note: Use the following function prototype.
Void swap(int *,int );
Print the result in main()
4]
Write a program to delete 3 bits from given position in each array element.
Take position from user.
Note: Use the following function prototype.
Void delete(int *,int );
Print the result in main()
5]
Write a program to check first digit of each array element is prime or not.
If it is prime reverse that element.
Example: int a[5]={152,2569,856,428,512};
Output: a[5]={152,9652,856,428,215};
Note: Use the following function prototype.
Void reverse(int *,int *);
Print the result in main()
6]
Write a program to replace each array element by the nth prime number from
the given array element.
Here n is number of prime digit in a given number.
Example: int a[5]={12,2,3,4,5};
Output: a[5]={13,3,5,4,7};
Note: Use the following function prototype.
Void replace(int *,int *);
void prime(int *,int *);
Print the result in main()
7]
Write a program to swap first and last word in a string if there length is prime.
Example:
Input: char s[20]=”Abcde 1234 12345”
Output: char s[20]=”12345 1234 Abcde”
Note: Use the following function prototype.
Void swap(char *);
void checkpirme(int *,int *);
Print the result in main()
8]
Write a program to count the word in a string whose length is prime.
If the count of such words is prime then reverse the alternate word in a
string.
Example:
Input Char s[20]=”ABC V25BE1 12”
2 words are there whose length is prime.
So revesre the alternate words.
Output char s[20]=”CBA V25BE1 21”
Note: Use the following function prototype.
Void countword (char *);
int checkprime(int *);
void reverse(char *);
Print the result in main()
9]
Write a program to delete a character whose data corresponding to second
nibble is prime.
Example:
Input char s[20]=”ayz V25BE1 cde”
Now data in second nibble of ‘a’ is 6 so as it is not a prime so character ‘a’ will
not be deleted.
But data in second nibble of ‘y’ and ‘z’ is 7 so delete both character.
Output:
char s[20] = “a BE cde”
Don’t delete space. Because space ascii value second nibble data is prime.
Note: Use the following function prototype.
int data (char *);
int checkprime(int *);
void delete(char *,char *);
Print the result in main()
10]
Given two non-negative integers num1 and num2 represented as strings, return
the product of num1 and num2, also represented as a string.
Example 1:
Input: num1 = "2", num2 = "3"
Output: "6"
Example 2:
Input: num1 = "123", num2 = "456"
Output: "56088"
11]
You are given two strings s and t.
String t is generated by random shuffling string s and then add one more letter
at a random position.
Return the letter that was added to t.
Example input char s[30]=”Abcde”
t[20]=”ebcdpA”
Letter added in string t is ‘p’.
So output of the string is ‘p’.
Note: Use the following function prototype.
Char random(char *,char *);
Print the result in main()
12]
Given a string s, sort it in decreasing order based on the frequency of the
characters. The frequency of a character is the number of times it appears in the
string.
Return the sorted string. If there are multiple answers, return any of them.
Example : Input char s[]=”VV25BE11”
Output char s[]=”VV1125BE”
Input char s[]=”11213113”
Output char s[]=”1111332”
Note: Use the following function prototype.
char * sort(char *);
13]
Write a program to reverse the first largest word from end.
Don’t disturbed other words.
Example Input char s[]=”abcd 1213567 bab abcdefg v25be1”
Output char s[]=”abcd 121356 bab gfedcba v25be1”
Note: Use the following function prototype.
void largest(char *,int*);
void findlargest(char *,char *);
void reverse(char *,int *);
Print the result in main()
14]
Given a 32-bit integer num, return a string representing its hexadecimal
representation. For negative integers, two’s complement method is used.
Note: Use the following function prototype.
Char * hex (int *);
Example Input int num=26;
Output string= “1a”
Input int num=256;
Output string =”100”
15]
Given an integer num, return a string of its base 7 representation.
Example 1:
Input: num = 100
Output: "202"
Example 2:
Input: num = -7
Output: "-10"
Note: Use the following function prototype.
Char * hex (int *);
16]
Write a Program to delete the lagest word in a string.
Follow the following function prototype.
Void largestword(char *,char *);
void delete(char *);
For example: ABCD PQRSTU Adil
Output : ABCD Adil
17]
Write a Program to reverse the alternate word in a given string.
Follow the following function prototype.
Void revese(char *);
For Example: Abcd V25Be1 4567 Shravan
Output: dcbA V25Be1 7654 Shravan
18]
Write a program to reverse the words whose length is odd
Follow the following function prototype.
Int length(char *);
void reverse(char *,int);
For Example: Adil 12347 45678 PQRS9
Output: Adil 74321 87654 9SRQP
19]
Write a program to replace all occurence of word “Bangalore” by Bengaluru in
a string.
Follow the following function prototype.
char * findword(char *);
void replace(char *,int );
20]
Write a program to sort the character in the words of minimum length.
For Example: Input char s[50]=”Abcd had shravan dba”
Output char s[50]=”Abcd adh shravan abd”
21]
Given two non-negative integers num1 and num2 represented as strings, return
the product of num1 and num2, also represented as a string.
Int intconvert(char *);
char *Asciiconvert(int *);
For Example: Input char s[50]=”123”
char s1[50]=”123”
Output=”15129”
22]
Reverse the word in a string.
Input char s[50]="the sky is blue"
Output char s[50]="blue is sky the"
23]
Take a float number from user and print that number in string format.
Input float f=12.005;
output Printf(“%s\n”,a); ---------12.005
where a is character array.
Follow the following function prototype.
Char * floattoascii(char *,float);
24]
Take one string from user.
For example char s[]=”V25BE1A”;
Write a program such that it will print following output.
V
V2
V25
V25B
V25BE
V25BE1
V25BE1A
V25BE1
V25BE
V25B
V25
V2
V
Write a generic program.
Take input as any string it should work for it.
Follow the following function prototype.
Void fun(char *);
25]
Take one array and replace each element of the array by count and that count
should represent how many prime number are there before that cooresponding
element.
For example
Input int a[5]={10,20,30,40,50};
Output a[5]={4,8,10,12,15}
where 4 is number of prime number before 10 and so on.
Follow the following function prototype.
Void prime(int *,int);
void prime count (int ,int*);
26]
Write a program to count how many prime numbers are there in given array
using function.
Take input in main function.
Print the count of prime numbers in main().
Follow the given function declaration.
void prime(int *,int *,int*);
27]
Write a program to count set bit in a given number using function.
Take three number from user and count set bit in each number using function
but print the result in main function.
Follow the given function declaration.
Void binary(int *,int *,int *);
28]
Write a program to count prime digit in a given number.
Take input in main function.
Print the count in main function.
Follow the given function declaration.
Void count_prime(int *,int *);
29]
Write a program to remove the digit which contain even set bit count.
Take input in main function.
Delete the digit which contain even set bit count using function but print the
result in main()
Follow the given function declaration.
Void even_delete(int *);
30]
Write a program to count element in the array whose sum is prime.
Take input in the main function.
Follow the given function declaration.
Void array_sum(int *,int * ,int *);
31]
Write a program to clear all the bit in the second byte of each array element and
print the result in the main function.
Use the following function declrartion.
Void array(int *,int *);
32]
Write a program to count the length of each word in a given string if the
wordlength is prime reverse the word.
Use Following function prototype.
void length(char *,int *);
void reverse(char *,int);
Example:
Input: Abcd 12345 abd
Output : Abcd 54321 dba
33]
Write a program to reverse the word for which set bit count is even in a string.
Use following function prototype.
set_count(char *,int *);
void reverse(char *);
34]
Write a program to replace each element of integer array by the fifth prime
number from the corresponding element.
Follow the given function prototype
void prime(int *,int *);
35]
Write a program to delete armstrong number in integer array.
Follow the given function prototype.
Void armstrong(int *,int *);
void power(int*, int *,int *);
void delete(int *,int *);
36]
Write a program to reverse the word which contain vowel.
Follow the given function prototype.
Int checkvowel(char *);
void reverse(char *);
37]
Write a program to reverse the number in the array if its first digit is odd.
Example: Int a[5]={123,245,312,599,600};
Output : a[5]={321,245,213,995,600};
int checkdigit(int );
void reverse(int *,int *);
38]
Write a program to delete first digit of each array element if that digit is prime
Example: Int a[5]={123,245,312,599,600};
Output : a[5]={123,45,12,99,600};
Follow the given function prototype.
Void delete(int *,int *);
void checkprime(int *,int *);
Print result in main.
39]
Write a program to find largest digit in each array element and replace that digit
with such a fifth number from largest digit which contain even set bit count
only when if that fifth number is prime. If fifth such a number which contain
even set bit count is not prime don’t replace largest digit with such a number.
Also if fifth such number is more than one digit then add digit until it does not
become single digit and then replace in place of largest digit.
Follow the given function prototype.
Void largest(int *,int *);
void fifthnumber(int *,int *);
void sum(int ,int*);
void replace (int *,int *);
Print result in main().
40]
Write a program to swap first digit and last digit in each array element if both
digit contain even set bit count.
Follow the given function prototype.
Void swap(int *,int *);
void setbit(int *,int *);
Note:
Once understand function try to do all LMS array and string question
using function and pointer only.
Write a generic code for every question. It should work for every input.