Search C Program

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;
}

4 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
  2. WAP on the given conditions:
    A financial institution provides following incentive policy for its customer for the deposit:
    a) for deposit of Rs. 5000 or above and time 2 years or above interest rate is 4%
    b) for deposit of Rs. 5000 or above and time less than 2 years interest rate is 3%
    c) on deposit below Rs. 5000 interest rate is 2% regardless of the period of the deposit

    ReplyDelete