Data types:
- Data Type Defines what type of value you can store in a Variable.
- Primary Data Types: int ,float ,char.
Int:
- Format Specifier = %d
- Keyword = int
- Space = 2 byte
- Range = -32768 to 32767
- Decimal values are allowed.
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b=0;
clrscr();
for( a=1 ; a<=50 ; a++ )
{
b=b+a; // It can also be written as b+=a
}
printf(" sum is =%d" , b);
getch();
}
Output:
Sum is =1275
0 Response to "Write a C Program to Calculate the Sum of First Fifty Numbers"
Post a Comment