# Problem

Page 1 of 1

## 2 Replies - 529 Views - Last Post: 12 May 2013 - 09:31 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=320852&amp;s=e941a301587683fb9d92776ddac0d445&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 saeee

Reputation: 0
• Posts: 2
• Joined: 12-May 13

# Problem

Posted 12 May 2013 - 02:23 AM

Hi, i am new to c language. please correct this.
i want the sum of first n numbers, and also prompt for another try

```
#include<stdio.h>
#include<ctype.h>
main ()
{
for (;;)/>
{
int sum = 0;
int number;
printf("\n Enter the number :");
scanf("%d", &number);
for (int i=1; i<=number; i=i+1)
{
sum=sum+i;
}
printf("\n the requested number %d , and the sum is %d ", number , sum );
printf("\n Wanna another try /n type Y or N :");
break;
}
return 0;
}

```

Is This A Good Question/Topic? 0

## Replies To: Problem

• Saucy!

Reputation: 6237
• Posts: 24,002
• Joined: 23-August 08

## Re: Problem

Posted 12 May 2013 - 02:49 AM

You don't say what the problem is, but try making this

```scanf("%c", &answer);
```

into this (notice the space)

```scanf(" %c", &answer);
```

If that doesn't fix the problem, then please TELL US what the problem is.

### #3 saeee

Reputation: 0
• Posts: 2
• Joined: 12-May 13

## Re: Problem

Posted 12 May 2013 - 09:31 PM

thanks a lot.