Beruflich Dokumente
Kultur Dokumente
[Q002] W.A.P. in C to find the Fifth root of the sum of the squares of the first 100 ODD
numbers only.
/* To find the Fifth root of the sum of the squares of the first 100 ODD numbers
ONLY */
#include< stdio.h >
#include< conio.h >
#include< math.h >
int main(void)
{
long i,oddnum=1,sqrnum,sum=0;
for (i=1; i<=100; i++)
{
sqrnum=oddnum * oddnum; // Square the ODD number
sum+=sqrnum; // Add Square value to the sum
oddnum+=2; // Get the next ODD number
}
printf("\nThe result is : %ld,%.2f",sum,pow((double)sum,(1.0/5.0)));
return(0);
} /* End of Main */
[Q004] W.A.P. in C to check whether given number x is equal to the value 2 POWER i or
something, where i>=0 using BITWISE operators ONLY. [Hint : Check whether the given
number x is equal to the value 2 POWER i or something using BITWISE operators
ONLY]
/* Check whether the given number x is equal to the value 2 power i or not using
BITWISE operators ONLY */
#include< stdio.h >
#include< conio.h >
int main(void)
{
long x;
printf("Enter a number : ");
scanf("%ld",&x);
if ((x & 0x1) == 0x0) // Checking the Least significant bit
printf("The given number %ld is EQUAL to the value 2 POWER
something",x);
else
printf("The given number %ld is NOT EQUAL to the value 2 POWER
something",x);
getch();
return(0);
} /* End of Main */
[Q005] W.A.P. in C to maintain 2 STACKS within a SINGLE ARRAY and the values of one stack
should not overwrite the values of another stack.
case 5 : Display();
break;
case 6 : exit(0);
} /* End of Main */
[Q006] W.A.P. in C that act as a guessing game in which the user has eight tries to
guess a
randomly generated number. The program will tell the user each time whether he
guessed high or
low. The user WINS the game when the number guessed is same as randomly
generated number.
} /* End of Main */
[Q007] W.A.P. to determine how much money is in a piggy bank that contains several
50 paise coins, 25 paise coins, 20 paise coins, 10 paise coins and 5 paise coins. Use the
following values to test your program : Five 50 paise coins, Three 25 paise coins, Two
20 paise coins, One 10 paise coin and Fifteen 5 paise coins. (Answer : Rs. 4.50)
} /* End of Main */
[Q008] Modify the program given in [Q007] to accept total amount (in rupees) and
convert them into paise.(Vice-versa of [Q007])
/* Denominations */
#include< stdio.h >
#include< string.h >
#include< conio.h >
int main(void)
{
int nc1,nc2,nc3,nc4,nc5,temp;
float total;
clrscr();
printf("Enter the amount : ");
scanf("%f",&total);
temp = total * 100;
nc1 = temp / 50;
temp = temp % 50;
nc5=temp;
} /* End of Main */
[Q09] W.A.P. in C to determine how many of the characters are vowels and how many
are consonants in a given line of text. Also terminate the string when the input
character encountered is other than the alphabets(a-z or A-Z) and Blank spaces.
[Hint:(a) When the input string is 'C FOR SWIMMERS, TEST YOUR C PROGRAMMING
STRENGTHS'. Consider the string 'C FOR SWIMMERS' only Because ',' is encountered.
(b) When the input string is 'Y2K PROBLEM'. Consider the character 'Y' only Because
the '2' is encountered.]
} /* End of Main */
[Q010] W.A.P. in C to perform 4-letter WORD UNSCRAMBLING i.e. List all possible
combinations of 4-letters in a word. Ex: The word 'TEST' can be unscrambled as
TEST,TETS,TSET,TSTE,TTSE,TTES,etc.
} /* End of Main */