WELCOME TO MY BLOG BY SHABEEB.K

C,C++ PROGRAMMING: CONVERT A LIST OF NUMBERS TO A SPECIFIED NUMBER.

Search This Blog

Wednesday, 4 September 2013

CONVERT A LIST OF NUMBERS TO A SPECIFIED NUMBER.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include<stdio.h>
#include<conio.h>
#include<string.h>
int n,i,i2,i3;

struct number
{
int number;
}num[50];
void main()
{
void read();
void display();
void replace();
clrscr();

printf("ENTER LIMIT OF HOW MANY NUMBER ENTER TO LIST\n");
scanf("%d",&n);

read();
display();
replace();
getch();
}

void read()
{
printf("ENTER NUMBERS\n");

for(i=1;i<=n;i++)
{
scanf("%d",&num[i].number);
}
}

void display()
{
for(i=1;i<=n;i++)
{
printf("\t %d , ",num[i].number);
}
}

void replace()
{
printf("\n \n REPLACE\t");

scanf("%d",&i2);
printf("\n \n TO\t");
scanf("%d",&i3);
printf("SPECIFIED NUMBER REPLACED \n");

for(i=1;i<=n;i++)
{
if(num[i].number==i2)
num[i].number=i3;
printf("%d ,",num[i].number);
}
}


No comments:

Post a Comment