Beginner in C

0 Hristiyan Zahariev · October 7, 2014

Hristiyan Zahariev
Hello guys,
I am very new at C programming language and I need your help.
I have to do a program that shows 0;-1;2;-3;4;-5;6.......100. (from 0 to 100)
Every odd is with "-" and every countable is with "+" .

#include <stdio.h>
int main()
{
int a = 0;
int b = -1;
for (a =0; a<=100; a+=2)
printf("%d\n",a);
for (b =-1; b>=-99; b-=2)
printf("%d\n",b);
}

I did this code but when I start it it does : 0;2;4;6;8;10;12;14.........100 and on the other line is : -1;-3;-5;-7;-9;-11.....-99
I am sorry for my bad English and looking forward hearing from you :).

Post a Reply

Replies

Oldest  Newest  Rating
0 Hristiyan Zahariev · October 7, 2014
Thank you man ! Now I realise it is easy :D. Thanks alot
  • 1

C

124,515 followers
About

One of the most popular languages of all time.

Links
Moderators
Bucky Roberts Administrator