10) Sample C Program to print ODD numbers from 1 to 100.
# include <stdio.h>
# include <conio.h>
main( )
{
int i;
clrscr( );
for (i = 1; i <= 100; i += 2)
printf("%d\n",i);
getch( );
}
11) Sample C Program to print natural numbers from 1 to 100 in reverse order.
# include <stdio.h>
# include <conio.h>
main( )
{
int i;
clrscr( );
for (i = 100; i >= 1; i --)
printf(“%d\n”,i);
getch( );
}
12) Sample C Program to print sum of the natural numbers from 1 to 100.
# include <stdio.h>
# include <conio.h>
main( )
{
int n, sum = 0, i;
clrscr( );
for (i = 1; i <= 100; i ++)
sum = sum + i;
printf("Sum of natural numbers from 1 to 100 is %d\n",sum);
getch( );
}
Comments
Post a Comment
Please share your opinions and suggestions or your experience in the comments section. This way we can all help each other...
Experienced guys can share their resumes at admin@interview-made-easy.com