Click here to Skip to main content
15,867,308 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
#include<stdio.h>
#include<conio.h>
int main()
{
    int num[10], i, a, pos, n;
    clrscr();
    printf("enter the no of element in the array:");
    scanf ("%d",&a);
    printf("Enter the array  element:");
    for(i=0;i<n;i++)
    {
        scanf("%d",&a);
    }
    printf("\n Array you enterd: \n");
    for (i=0; i<n; i++)
    {
        printf("a[%i]=%i",i, a);
        a=a;
        for(i=5; i>=pos; i--)
            a==a-1;
        a-1==a;
        printf("Array with elemet added");
        for(i=0; i<n; i++)
            printf("\n %d=%d=", i+1, num[i]);
    }
    return(0);
}


What I have tried:

When I hit run elemets are added but after it there is nothing happen.... no error are showing
Posted
Updated 27-Nov-22 2:07am
v2
Comments
Richard MacCutchan 27-Nov-22 7:57am    
I have added the correct indentation to your code, so it is actually easy to read.

1 solution

Some comments on your code:
C++
#include<stdio.h>
#include<conio.h>
int main()
{
    int num[10], i, a, pos, n;
    clrscr();
    printf("enter the no of element in the array:");
    scanf ("%d",&a);            // *** you never do anything with this value
    printf("Enter the array  element:");
    for(i=0;i<n;i++)            // *** you have not stored a value in 'n'
    {
        scanf("%d",&a);         // *** you save every value in the same variable - 'a'
    }
    printf("\n Array you enterd: \n");
    for (i=0; i<n; i++)         // *** you still have no value in 'n'
    {
        printf("a[%i]=%i",i, a); // *** this statement makes no sense since a is not an array
        a=a;                     // *** this makes no sense as it does nothing
        for(i=5; i>=pos; i--)    // *** you have not stored a value in 'pos'
            a==a-1;              // *** a can never be equal to a-1
        a-1==a;                  // *** and a-1 can never be equal to a
        printf("Array with elemet added");
        for(i=0; i<n; i++)
            printf("\n %d=%d=", i+1, num[i]); // *** you have not saved anything in the 'num' array.
    }
    return(0);
}


So I suggest you throw this code away and start again. But first think exactly what you need this code to do, write the steps out on paper, and take it one step at a time.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900