Nov 21, 2017, 02:23 AM

News:

Recent Website Purchased by Us : Enthiran


For Loop Programs in C

Started by karthikn, Aug 06, 2008, 09:38 PM

previous topic - next topic
Go Down

karthikn

Programming in C to print the number between two ranges

#include <stdio.h>
#include <conio.h>

int main()

{

int M,N;

printf("enter the ranges do you want diaplay\n");

scanf("%d%d",&M,&N);

printf("the numbers between %d to %d \n",M,N);

for(;M<=N;M++)
printf("%d  ",M);

getch();



Display the leap Years between 1000 and 2000

#include <stdio.h>
#include <conio.h>

int main()

{

int loop;

printf("the leap year or not between 1000 to 2000\n");

for(loop=1000;loop<=2000;loop++)
{

if(loop%4==0)
printf("%d  leap year\n",loop);
else
printf("%d  not\n",loop);
}
getch();


Dnyaneshwar Chavan

Sorry, but its not a perfect programme ....
To find a leap year, following programme is more perfect.
#include <stdio.h>
int main(){
        int year;
        printf("Enter the year\n");
        scanf("%d",&year);
        if(year % 4 == 0){
                if(year % 100 == 0){
                        if(year % 400 == 0)
                                printf("Leap Year\n");
                        else
                                printf("Not a leap year\n");
                }
                else
                        printf("Leap Year\n");
        }
        else
                printf("not a leap year\n");


        return 0;
}                             

naveen kumar T

Programming in C to print the number between two ranges

#include <stdio.h>
#include <conio.h>

int main()

{

int M,N;

printf("enter the ranges do you want diaplay\n");

scanf("%d%d",&M,&N);

printf("the numbers between %d to %d \n",M,N);

for(;M<=N;M++)
printf("%d  ",M);

getch();



Display the leap Years between 1000 and 2000

#include <stdio.h>
#include <conio.h>

int main()

{

int loop;

printf("the leap year or not between 1000 to 2000\n");

for(loop=1000;loop<=2000;loop++)
{

if(loop%4==0)
printf("%d  leap year\n",loop);
else
printf("%d  not\n",loop);
}
getch();



Go Up
 

Quick Reply

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Note: this post will not display until it's been approved by a moderator.
Name:
Email:
Verification:
Please leave this box empty:

Type the letters shown in the picture
Listen to the letters / Request another image

Type the letters shown in the picture:

shortcuts: alt+s submit/post or alt+p preview
IT Acumens | GinGly :: SMS Backup | Acumen :: Discussion Board | AshokPillar :: Hosting | CineBuzz :: Latest Cinema News | My Kids Diary :: Capture your kids magical moment
Copyright 2005 - 2017 :: IT Acumens :: All Rights Reserved.
ITAcumens Forum with 2 lakhs post running for 10 years - Powered by HostGator Dedicated Server