Posts

Showing posts from March, 2010

Feminists

Image
During tech-fest in my campus… Isn’t this concept funny?

WAP to count and print the number of negative and positive numbers in a given set of numbers. Test your program with a suitable set of numbers. Use scanf() to read the numbers. Reading should be terminated when the value 0 is encountered

//E Balagurusamy, Programming In ANSI C,4E
//Exercise 2.6, page 51
#include <stdio.h>
#include <conio.h>
int main(void)
{
int n=0, positive=0, negative=0;

WAP to input price of one kg of rice and one kg of sugar print them in an appropriate manner (like 2 decimal places for money)

//E Balagurusamy, Programming In ANSI C,4E
//Exercise 2.5, page 51
#include <stdio.h>
#include <conio.h>
int main(void)
{
float price_rice=0.0, price_sugar=0.0;
//input prices
printf("Enter price of 1 kg rice  : ");
scanf("%f",&price_rice);

WAP that requests two float type numbers from the user and then divides the first number by the second and displays the result along with the numbers

//E Balagurusamy, Programming In ANSI C,4E
//Exercise 2.4, page 51
#include <stdio.h>
#include <conio.h>
int main(void)
{float input_first=0.0, input_second=0.0, div=0.0;

WAP that prints the even numbers from 1 to 100

//E Balagurusamy, Programming In ANSI C,4E
//Exercise 2.3, page 51
#include <stdio.h>
#include <conio.h>
int main(void)
{int i=0;
printf("\n\n");
printf("===Even Numbers From 1 To 100===\n\n");
for (i=1; i<=100; i++)
    {if ((i%2)==0)
        {printf("%d\t",i);
        }
    }
//"There are more ways to solve this simple problem,
//like beginning the loop from 2 and incrementing by +2
//printing index at each iteration...
//Personally, I like this version better"
getch();
return 0;
}

WAP to read the price of an item in decimal form (like 15.95) and print the output in paise (like 1595 paise)

//E Balagurusamy, Programming In ANSI C,4E
//Exercise 2.2, page 51
#include <stdio.h>
#include <conio.h>
#include <math.h>
int main(void)
{float amount_input=0.0;
int amount_in_paise=0;

WAP to determine and print the sum of the following harmonic series for a given value of n: 1 + (1/2) + (1/3) + (1/4) + ... + (1/n)

The value of n should be given interactively through the terminal.

//E Balagurusamy, Programming In ANSI C,4E
//Exercise 2.1, page 51
#include <stdio.h>
#include <conio.h>
int main(void)
{int n=0, i=0;

WAP to implement DDA Digital Differential Analyzer

Image
//DDA Line Rasterization Algorithm

//Practical assignment under MCA (TYC)- Sem IV
//Guru Nanak Dev University, Amritsar Campus

#include <iostream.h>
#include <math.h>
#include <conio.h>

int main(void)
{
cout<<endl<<endl;

int x1, y1; //starting point
int x2, y2; //ending point

A Simple Mistype Of Equal Sign As Hyphen Cost Me About 20 Minutes

Image