write a program to insert an element into an array
Answer Posted / sonia
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
main()
{
int a[10]={10,20,30,40,50,60,70,80,90};
int num,i,pos;
printf("enter the no which you want to insert");
scanf("%d",&num);
printf("enter the position");
scanf("%d",&pos);
if(pos<0 || pos>9)
{
printf("invalid position");
getch();
exit(0);
}
for(i=9;i>pos;i--)
a[i]=a[i-1];
a[pos]=num;
for(i=0;i<=9;i++)
printf(" %d",a[i]);
getch();
}
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
How is modularity introduced in C++?
What is lazy initialization in c++?
What are the unique features of C++.
Describe public access specifiers?
What is code reusability in c++?
How did c++ start?
What is an iterator?
What is the difference between a reference and a pointer?
A company pays its salespeople on a commission basis. The salespeople receive $200 per week plus 9 percent of their gross sales for that week. For example, a saleperson who sells $5000 worth of merchandise in a week receives $200 plus 9 percent of $5000, or a total of $650. You have been supplied with a list of items sold by each salesperson. The values of these items are as follows: Item Value A 239.99 B 129.75 C 99.95 D 350.89 Write a program that inputs one salesperson's items sold in a week (how many of item A? of item B? etc.) and calculates and displays that salesperson's earnings for that week.
Where is atoi defined?
How can you link a c program with a c function?
State two differences between C and C++.
What is the rule of three?
What is private inheritance?
What is a lambda function c++?