Search C Program

Loading...

Print 1 to 10


/* Print 1 to 10 using while loop */
#include<stdio.h>
int main()
{
    int i=1;
    while(i <= 10)
    {
        printf("%d\n",i);
        i++;
    }
    return 0;
}

---------------------------------------------

/* Print 1 to 10 using for loop */
#include<stdio.h>
int main()
{
    int i;
    for(i=1;i<=10;i++)
        printf("%d\n",i);
    return 0;
}

3 comments:

  1. Q1. Write a program to read 10 numbers and compute the average, maximum and minimum values

    Q2. Write a program to read in numbers until the number -999 is encountered. The sum of all number read until this point should be printed out.

    ReplyDelete