473,398 Members | 2,427 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Write a program that estimates the of integer numbers 1 to N

1
your program should read the integer number N and be sure N> 5.
May 8 '10 #1
1 1352
0nur
1
your main function

Expand|Select|Wrap|Line Numbers
  1. int number=0;
  2. int result=0;
  3.  
  4. scanf("%d" &number);
  5.  
  6. if (number > 5)
  7. {
  8.   while(number)
  9.   {
  10.   result += number;
  11.   number--;
  12.   }
  13.  
  14.   printf("%d", result);
  15. }
  16. else
  17.   printf("enter a number bigger than 5");
  18.  
  19.  
May 8 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Simon Wigzell | last post by:
I recently wrote a program with MS Visual Studio C++, sent it off to the client where it didn't run, after some probing I discover they are on a Mac! My program is a MSF interface that is really...
22
by: Saurabh Saxena | last post by:
can we write the program to write no 1 to n without using switch,do,while,for,goto,if and conditional operator where n will be input by user.
0
by: Tom | last post by:
I am new to hardware programming. I need to write a program for reading data from Card Reader which connects to the PC windows 2000/XP OS through Interfacing The Serial / RS-232 Port / USB /...
10
by: Ron | last post by:
I want to calculate the surface area of a sphere from an inputed radius with option strict on. I guess I am not converting something correctly. Here is what I am doing: I have a textbox...
1
by: psalmprax | last post by:
who can write a C-program on perfect numbers from 1 to 1000?
1
by: apryladams | last post by:
i need to display 25 numbers in 5 output lines -5 numbers per line calculate sum and average those 25 vnumbers display sum and avergae on page output sum and average into an output file. find...
4
by: sandeepmshetty | last post by:
help me to solve the following program in shortest form.... Write a program to output any number between 1 and 99999 and output it in words. For example: If the number is 213 then it should...
5
by: =?Utf-8?B?Y2hyaXNiZW4=?= | last post by:
Hi, I try to use an integer to pass 4 kinds of information. Each kind may have 5 types. I plan to use an integer like 2034, while 2 0 3 4 are corresponding to the type of each kind. I am...
1
by: monkey0525 | last post by:
I'm writing a program that reads information from three seperate classes. Here is my code: public class Animal { protected int id; protected String type; protected double mass; ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.