-->

program to display all numbers which are stored in odd positioned cell of array


using turbo C++
-----------------------------------------------------------------------
// program to display all numbers which are stored in odd positioned cell of array
#include <stdio.h>
#include<conio.h>
void main()
{
    int a[100],n,i;
    printf("enter total number\n");
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        printf("enter number for location=%d\n",i);
        scanf("%d",&a[i]);
    }
    printf("numbers are:\n");
    for(i=0;i<n;i++)
    {
        if(i%2!=0)
                {
                   printf("%d\n",a[i]);
                 }
    }
    getch();
}


-------------------------------------------------------------------------------------------------------------------
using online compiler/devC++/codeblocks with return concept
---------------------------------------------------------------------------------------------------------------------
// program to display all numbers which are stored in odd positioned cell of array

#include <stdio.h>

int main()
{
    int a[100],n,i;
    printf("enter total number\n");
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        printf("enter number for location=%d\n",i);
        scanf("%d",&a[i]);
    }
    printf("numbers are:\n");
    for(i=0;i<n;i++)
    {
        if(i%2!=0)
                {
                   printf("%d\n",a[i]);
                 }
    }
    return 0;
}

No comments:

Post a Comment