Phuck U

Topics: Addition, Division, Integer Pages: 1 (308 words) Published: May 19, 2013
Assignment Module: C Programming Language Learning Units: a) Introduction to C language b) Operators and basic types c) Control flow 1. Write a Program to input three positive integers representing the sides of a triangle and determine whether they form a valid triangle or not. 2. To round off a floating point number to the nearest integer, one adds 0.5 to the number and truncates it to an integer. Using this knowledge, try to figure out how to round a floating point number to the nearest tenth, hundredth, etc and implement the same. 3. Write a program that repeatedly ask the user to input a negative or positive number, and then echoes it. When the value 0 is entered, the program should terminate. It also keeps a count of how many of the numbers are positive and how many are negative. The program should print out these two totals immediately before terminating. 4. Write a program to which accepts a number n, and then finds the sum of the integers from 1 to 2, then from 1 to 3, then 1 to 4 and so forth until it displays the sum of the integers from 1 to n. For example, if the input is 5, the output will be 1 3 6 10 15 5 Write a program to implement the Russian Peasant Problem for multiplying two positive numbers using while or do…while loop. Russian Peasant problem is a method of multiplying two numbers together, using only division by 2, multiplication by 2 and addition. For example, if the numbers are 17 and 19are to be multiplied together, they are put at the head of two columns: The first number is divided by 2 and the second number is multiplied by 2. This process is continued until the number on the left reduces to 1.

Continue Reading

Please join StudyMode to read the full document

You May Also Find These Documents Helpful

  • U-571 Management 3110 Essay
  • The German U-Boat Campaign Essay
  • Study of Hypothesis- H test and U test Essay
  • U Are What U Wear Research Paper
  • U Essay
  • Essay about The U
  • Essay about Fck U
  • Essay about true to u

Become a StudyMode Member

Sign Up - It's Free