Input five numbers in an array and a single number. Write a program to store that single number in the zero element of the array.
#include <stdio.h>
#include <conio.h>
void main ( )
{
int co, no[50], n, tot =5;
clrscr ( );
for ( co = 0; co < 5; co++ )
{
printf ("\n\t\t\t Enter a number...........:"); scanf ("%d", &no[co]);
}
while ( 1 )
{
printf ("\n\n\n\t\t\t Enter a number ...< zero to end >...........:"); scanf ("%d", &n);
if ( n == 0 )
break;
for ( co = tot - 1; co >= 0; co-- )
{
no[co + 1] = no[co];
}
no[0] = n;
printf ("\n\n Numbers are :");
for ( co = 0; co <= tot; co++)
{
printf(" %d", no[co] );
}
tot++;
}
getch ( );
}
Click here to contact us
No comments:
Post a Comment