Showing posts with label C Language. Show all posts
Showing posts with label C Language. Show all posts

Wednesday, 16 April 2014

Program to Check Whether a Given String is Palindrome or Not

/* Write an Interactive C Program to Check Whether a Given String is Palindrome or Not, Using Pointer*/
main()
{
 char ch[20],a[20],*p;
 int i,len,c=0;
 clrscr();

Program to Replace a Character in a String.

/*Write a function strreplace(s,chr,repl_chr) which will replace each occurrences of character chr with the character repl_chr in the string s. The function returns the number of replacements.*/

int strreplace(char [],char,char);
main()
{
 char s[160],c,r;
 int i;
 clrscr();
 printf("Enter any string \(word or sentence\).\n");

Program to Convert a Binary Number to Its Octal Equivalent.

main()
{
 int bin[16],i,oct[16],s,os,j,x,r;
 clrscr();
 printf("Enter the number of bits you want to insert. --> ");

Saturday, 29 March 2014

Program To Calculate and Report the Owed Income Tax Amount

/* Assume that the United States of America uses the following income tax code formula for their annual income:
First US$ 5,000 of income: 0% tax
Next US$ 10,000 of income: 10% tax
Next US$ 20,000 of income: 15% tax
Next  Amount upto and above US$ 35,000: 20% tax.
For example, somebody earning US$ 38,000 annually would owe

Program To Check Whether Given Two Numbers Are Amicable Numbers or Not

/*Amicable Numbers are two numbers so related that the sum of the proper divisors of the one is equal to the other, unity being considered as a proper divisor but not the number itself. Such a pair is (220, 284).*/

Monday, 25 February 2013

Program to take any number from 1 to 999 and display its name.


main()
{
 int num,number;
 char ch;
 while(1)
 {
 clrscr();
 printf("\nEnter any number between 0 to 1000 :-\nNumber = ");

Tuesday, 18 September 2012

Program for Programming Language Knowledge Test in multiple choice


main()
{
 char c;
 printf("This is your Programming Language Knowledge Test of C, developed in C by the \"Amit Ranjan\".\n");
 printf("There are 20 multiple Choice Question of 5 marks each.\n");

Tuesday, 11 September 2012

If the three sides of a triangle are entered through the keyboard, write a program to check whether the triangle is isosceles, equilateral, scalene or right angled triangle.


main()
{
 int a,b,c;
 printf("Enter the sides of a triangle :- ");
 scanf("%d%d%d",&a,&b,&c);
 if((a>b && a>c) && a<(b+c) || (b>a && b>c) && b<(a+c) || (c>a && c>b) && c<(a+b) || (a==b && b==c))
 {
  if(a==b && b==c)

In a company, worker efficiency is determined on the basis of the time required for a worker to complete a particular job. If the time taken by the worker is between 2 – 3 hours, then the worker is said to be highly efficient. If the time required by the worker is between 3 – 4 hours, then the worker is ordered to improve speed. If the time taken is between 4 – 5 hours, the worker is given training to improve his speed, and if the time taken by the worker is more than 5 hours, then the worker has to leave the company. If the time taken by the worker is input through the keyboard, find the efficiency of the worker.


main()
{
 float time;
 printf("Enter the time taken by the worker in hours (hh.mm) :- ");

The policy followed by a company to process customer orders is given by the following rules: (a) If a customer order is less than or equal to that in stock and has credit is OK, supply as requirement. (b) If has credit is not OK do not supply. Send him intimation. (c) If has credit is Ok but the item in stock is less than has order, supply what is in stock. Intimate to him data the balance will be shipped. Write a C program to implement the company policy.


main()
{
 int p;
 char cr;
 printf("Enter the customer order :- ");
 scanf("%d",&p);

Write a program to find the greatest of the three numbers entered through the keyboard using conditional operators.


main()
{
 int n1,n2,n3,num;
 printf("Enter any three numbers :- \n");

Thursday, 30 August 2012

If a five-digit number is input through the keyboard, write a program to print a new number by adding one to each of its digits. For example if the number that is input is 86932 then the output should be displayed as 97043.


main()
{
long num,a,b,c,d,e,new;
clrscr();
printf("Enter a five digit number\n");

If the total selling price of 15 items and the total profit earned on them is input through the keyboard, write a program to find the cost price of one item.


main()
{
 float sp,p,cp;
 printf("Enter total selling price and total profit earned on 15 items\n");

A cashier has currency notes of denominations 10, 50 and 100. If the amount to be withdrawn is input through the keyboard in hundreds, find the total number of currency notes of each denomination the cashier will have to give to the withdrawer.


main()
{
 int ten,fifty,hundred,cash;
 printf("Enter amount in multiple of hundred\n");

In a town, the percentage of men is 52. The percentage of total literacy is 48. If total percentage of literate men is 35 of the total population, write a program to find the total number of illiterate men and women if the population of the town is 80,000.


main()
{
 long t,m,w,lm,lw,l,im,iw;
 t=80000;
 m=80000*52/100;
 w=t-m;

If a four-digit number is input through the keyboard, write a program to obtain the sum of the first and last digit of this number.


main()
{
 int num,f,l,sum;
 printf("Enter a four digit number\n");

If a five-digit number is input through the keyboard, write a program to reverse the number.


main()
{
 long num,a,b,c,d,e,rev;
 printf("Enter a five digit number\n");
 scanf("%ld",&num);