Get Email Subscription

Enter your email address:

Delivered by FeedBurner

Thursday, March 11, 2010

Find highest, median and lowest number from the given set of 17 numbers.

The Big Short: Inside the Doomsday Machine
Write a program in C to input 17 observation and then print highest, median and lowest.
#include<stdio.h>
#define N 17
void main( )
{
int i, j, n[N], t;
printf("Enter %d integer values\n", N);
for (i=0; i < N; i++) scanf("%d", &n[i]); for(i=0; i < N-1; i++) for (j=i+1; j < N; j++) if (n[i] > n[j])
{
t = n[i];
n[i] = n[j];
n[j] = t;
}
printf("Highest number is %d", n[16]);
printf("Median is %d\n", n[8]);
printf("Lowest number is %d", n[0]);
getch( );
}
read more "Find highest, median and lowest number from the given set of 17 numbers."

Find the highest and lowest number from the given set of 13 numbers.

Write a program in C to input 13 observation and then print Highest and Lowest.


#include<stdio.h>
#define N 13
void main( )
{
int i, j, n[N], t;
printf("Enter %d integer values\n", N);
for (i=0; i < N; i++)
scanf("%d", &n[i]);
for(i=0; i < N-1; i++)
for (j=i+1; j < N; j++)
if (n[i] > n[j])
{
t = n[i];
n[i] = n[j];
n[j] = t;
}
printf("Highest number is %d", n[12]);
printf("Lowest number is %d", n[0]);
getch( );
}
read more "Find the highest and lowest number from the given set of 13 numbers."

Input 10 numbers. Find the lowest number from the given set of 10 numbers.

Write a program in C to input 10 observation and then print Lowest.


#include<stdio.h>
#define N 10
void main( )
{
int i, j, n[N], t;
printf("Enter %d integer values\n", N);
for (i=0; i < N; i++)
scanf("%d", &n[i]);
for(i=0; i < N-1; i++)
for (j=i+1; j < N; j++)
if (n[i] > n[j])
{
t = n[i];
n[i] = n[j];
n[j] = t;
}
printf("Lowest number is %d", n[0]);
getch( );
}

read more "Input 10 numbers. Find the lowest number from the given set of 10 numbers."

Input 25 numbers. Find the largest number from the given set of 25 numbers.

Write a program in C to input 25 observation and then print Highest.


#include<stdio.h>
#define N 25
void main( )
{
int i, j, n[N], t;
printf("Enter %d integer values\n", N);
for (i=0; i < N; i++)
scanf("%d", &n[i]);
for(i=0; i < N-1; i++)
for (j=i+1; j < N; j++)
if (n[i] > n[j])
{
t = n[i];
n[i] = n[j];
n[j] = t;
}
printf("Highest number is %d", n[24]);
getch( );
}
read more "Input 25 numbers. Find the largest number from the given set of 25 numbers."

Input 15 numbers. Arrange the numbers in ascending order and display the median of the same.

Write a program in C to accept 15 numbers, arrange these numbers in ascending order, display the median of the same.


#include< stdio.h>
#define N 15
void main( )
{
int i, j, n[N], t;
printf("Enter %d integer values\n", N);
for (i=0; i < N; i++)
scanf("%d", &n[i]);
for(i=0; i < N-1; i++)
for (j=i+1; j < N; j++)
if (n[i] > n[j])
{
t = n[i];
n[i] = n[j];
n[j] = t;
}
printf("Median is %d\n", n[7]);
getch( );
}
read more "Input 15 numbers. Arrange the numbers in ascending order and display the median of the same."

Input 20 numbers. Arrange the numbers in ascending order and display ascending order as well as descending order list.

Write a program in C to input 20 integers and then print these integers in ascending order of magnitude and then in descending order of magnitude.


#include<stdio.h>
#define N 20
void main( )
{
int i, j, n[N], t;
printf("Enter %d integer values\n", N);
for (i=0; i < N; i++)
scanf("%d", &n[i]);
for(i=0; i < N-1; i++)
for (j=i+1; j < N; j++)
if (n[i] > n[j])
{
t = n[i];
n[i] = n[j];
n[j] = t;
}
printf("The ascending order is \n");
for (i=0; i < N; i++)
printf("%d\t", n[i]);
printf("The descending order is \n");
for (i=N-1; i > = 0; i--)
printf("%d", n[i]);
getch( );
}
read more "Input 20 numbers. Arrange the numbers in ascending order and display ascending order as well as descending order list."

Input 20 numbers. Arrange the numbers in descending order and display descending order. (Sorting of an array)

Write a program in C accept 20 integers and arrange them in the descending order of values.(Sorting of an array)


#include<stdio.h>
#define N 20
void main( )
{
int i, j, n[N], t;
printf("Enter %d integer values\n", N);
for (i=0; i < N; i++)
scanf("%d", &n[i]);
for(i=0; i < N-1; i++)
for (j=i+1; j < N; j++)
if (n[i] < n[j])
{
t = n[i];
n[i] = n[j];
n[j] = t;
}
printf("The descending order is \n");
for (i=0; i < N; i++)
printf("%d\t", n[i]);
getch( );
}
read more "Input 20 numbers. Arrange the numbers in descending order and display descending order. (Sorting of an array)"

Input 10 numbers. Arrange the numbers in ascending order and display ascending order. (Sorting of an array)

Write a program in C accept 10 integers and arrange them in the ascending order of values.(Sorting of an array)


#include<stdio.h>
#define N 10
void main( )
{
int i, j, n[N], t;
printf("Enter %d integer values\n", N);
for (i=0; i < N; i++)
scanf("%d", &n[i]);
for(i=0; i < N-1; i++)
for (j=i+1; j < N; j++)
if (n[i] > n[j])
{
t = n[i];
n[i] = n[j];
n[j] = t;
}
printf("The ascending order is \n");
for (i=0; i < N; i++)
printf("%d\t", n[i]);
}
read more "Input 10 numbers. Arrange the numbers in ascending order and display ascending order. (Sorting of an array)"

Wednesday, March 10, 2010

Calculation of depreciation , by using Written Down Value ( WDV ) as well as Straight Line Method ( SLM ).

Enter cost, rate of depreciation and number of years. Display depreciation for each year by WDV method as well as by Straight Line Method.


#include<stdio.h>
#include<conio.h>
void main( )
{
float cost, rate, year, slmdep, wdvdep, cnt;
clrscr( );
printf("Enter Cost, Dep.Rate, Years");
scanf("%f %f %f", &cost, &rate, &year);
slmdep = cost*rate/100;
for (cnt=1; cnt < = year; cnt++)
{
wdvdep = cost*rate/100;
cost = cost - wdvdep;
printf("\n Year %f, WDV Dep %.2f, SLM Dep %.2f\n", cnt, wdvdep,slmdep);
}
getch( );
}


read more "Calculation of depreciation , by using Written Down Value ( WDV ) as well as Straight Line Method ( SLM )."

Calculation of depreciation by using straight Line method ( SLM )

Enter cost, rate of depreciation and number of years. Display depreciation for each year by straight line method.


#include<stdio.h>
#include<conio.h>
void main( )
{
float cost, rate, year, dep, cnt;
clrscr( );
printf("Enter Cost, Dep.Rate, Years");
scanf("%f %f %f ", &cost, &rate, &year);
dep = cost*rate/100;
for(cnt=1; cnt < = year; cnt++)
{
printf("\n Year %f, Depreciation %.2f\n", cnt, dep);
}
getch( );
}
read more "Calculation of depreciation by using straight Line method ( SLM )"

Calculation of depreciation by using WDV method

Enter cost, rate of depreciation and number of years. Display depreciation for each year by WDV method.


#include<stdio.h>
#include<conio.h>
void main( )
{
float cost, rate, year, dep, cnt;
clrscr( );
printf("Enter Cost, Dep.Rate, Years");
scanf("%f %f %f", &cost, &rate, &year);
for (cnt=1; cnt < = year; cnt++)
{
dep = cost*rate/100;
cost = cost - dep;
printf("\n Year %f, Depreciation %.2f\n", cnt, dep);
}
getch( );
}
read more "Calculation of depreciation by using WDV method"

Calculation of depreciation , by using WDV method & scrap value at the end

Write a program in C which will get from the keyboard information about the name of the asset for which depreciation is to be calculated according to diminishing balance method. The operator should also give detail about the cost price of the asset and the rate of depreciation and number of years indicating the life of the asset. The output must show year number (real), value of the asset of that year, depreciation for the year and at end it should indicate the scrap value of the asset.


#include<stdio.h>
#include<conio.h>
void main( )
{
char asset_name[25];
float cost, rate, year, dep, cnt;
clrscr( );
printf("Enter Name of asset, cost, Dep, Rate, Life of asset");
scanf("%s %f %f %f", asset_name, &cost, &rate, &year);
for (cnt=1; cnt < = year; cnt++)
{
dep = cost*rate/100;
printf("\n Year %.0f, Cost this year %.2f, Depreciation %.2f\n", cnt, cost, dep);
cost = cost - dep;
}
printf("Scrap value %.2f\n", cost);
getch( );
}
read more "Calculation of depreciation , by using WDV method & scrap value at the end"

Find the GCD of two positive integer.

Find the G.C.D of two positive integer.


#include<stdio.h>
#include<conio.h>
void main( )
{
int a, b;
clrscr( );
printf("Enter any two positive integer\n");
scant("%d %d", &a, &b);
while (a!=b)
{
if (a > b)
a = a - b;
else
b = b - a;
}
printf("The gcd is %d \n", a);
}
read more "Find the GCD of two positive integer."

Write a program in c ( WAPIC ) to input salesman name and his total sales and print his name, his commission and the additional commission.

A chemical co. offers commission to their salesman at rate of 5% of the total sales amount in order to increase the sales, the company offers an additional commission at 3% of the amount exceeding Rs. 10,000.
Write a prWrite a proogram in c ( WAPIC ) to input salesman name (sn) and his total sales (ts) and print his name, his commission (c) and the additional commission (ac).



#include<stdio.h>
void main( )
{
char sn[25];
float ts, c, ac;
printf("Enter the salesman name and his total sales\n");
scanf("%s %f", sn, &ts);
c = ts*0.05;
if (ts > 10000)
ac = (ts - 10000)*0.03;
else
ac = 0;
printf("Salesman name is %s \n", sn);
printf("His commission is Rs %f \n", c);
printf("The additional commission is Rs %f \n", ac);
}

read more "Write a program in c ( WAPIC ) to input salesman name and his total sales and print his name, his commission and the additional commission."

To display the numbers in the series, only 7 numbers per line

To display a series of numbers as 1 2 3 4 .......... 100. Display only five integers per line.


#include<stdio.h>
#include<conio.h>
void main( )
{
int j, p=0;
for (j=1; j < = 100, j++)
{
printf("%d", j);
p++;
if (p==7)
{
printf("\n");
p=0;
}
}
}

Hint:-


Method used in previous question can not be used
here. That method can be used only if 80 divided by
number of values per line gives you integer answer
otherwise you have to use 2nd Method.
7 values per line = 80/7 = 11.43 and
therefore you can not use the earlier method.

read more "To display the numbers in the series, only 7 numbers per line"

Tuesday, March 2, 2010

Write a program in C to display the number from 1 to 200 in a series. Print 20 numbers on one line and use all the available columns on the screen.

Write a program in C to display the number from 1 to 200 in a series.
Print 20 numbers on one line and use all the available columns on the screen.


#include<stdio.h>
#include<conio.h>
main( )
{
int i;
clrscr( );
for (i=1; i < = 200; i++)
{
printf("%4d", i);
}
return(0);
}

Hint:-


20 values per line = 80/20 = 4 = %4d
4 values per line = 80/4 = 20 = %20d
8 values per line = 80/8 = 10 = %10d


read more "Write a program in C to display the number from 1 to 200 in a series. Print 20 numbers on one line and use all the available columns on the screen."

Write a program in C to display the number form 1 2 3 4 .................100. Display only five integers per line.

Write a program in C to display the number form 1 2 3 4 .................100.
Display only five integers per line.


#include<stdio.h>
#include<conio.h>
main( )
{
int i;
clrscr( );
for (i=1; i < = 100; i++)
{
printf("%16d", i);
} return(0);
}

Hint:-


5 values per line = 80/5 = 16 = %16d
4 values per line = 80/4 = 20 = %20d
8 values per line = 80/8 = 10 = %10d


read more "Write a program in C to display the number form 1 2 3 4 .................100. Display only five integers per line."

About This Blog

Lorem Ipsum

  © Blogger templates Newspaper III by Ourblogtemplates.com 2008

Back to TOP