Archive Pages Design$type=blogging

Write a Program in C to Find if a Number is Present in a List or not

Here is a C program to find if a number is present in a list of N numbers or not. In this program for loop is used to search a number from t...


C Program to Find if a Number is Present in a List
Here is a C program to find if a number is present in a list of N numbers or not.


In this program for loop is used to search a number from the list of numbers and array of numbers is used to insert numbers in a list.


If the searched number is matched with any number in the list it throws to print it is presented in the list and if the searched number is not matched with any number in the list it throws to print it is not presented in the list.







 A C Program to Find if a Number is Present in a List of N numbers or not





Steps:
  1.  At first declare integers i, n, m, and array of integers a[10].
  2. Print the message to enter how many elements want to insert and allow to insert.
  3. Print the message to enter the elements in the array.
  4. Use for loop to find out whether the given number is present in the list or not.
  5. Print the message on the screen whether the given number is present in the list or not.




Code:



#include<stdio.h>
#include<conio.h>

void main()
{
int i,n,m,flag=0; int a[10];
clrscr();

printf("How many elements you want to enter \n");
scanf("%d",&n);

printf("Enter element in the array \n");
for (i=0; i<n; i++)
scanf("%d", &a[i]);

printf("Enter the element you want to search \n");
scanf("%d", &m);

for (i=0; i<n; i++)
{
if(a[i]==m)
{
flag=1;
break;
}
}
if(flag==0)
printf("Not present");
else
printf("Present");
getch();
}




Related Posts:



تعليقات

الاسم

Artificial Intelligence(AI) Backlinking Basic IT Best List Blogging Tips C C# C++ Computer Architecture Computer Fundamental Computer Security Computer/IT Officer Exam CSS Data Mining and Warehousing Data Recovery Tools Data Structure Database Management System E-commerce E-government Internet & Web Designing IT Law IT Tips and Tricks IT Tutorials Java JavaScript Keyword Research Tools MIS Multiple Choice Question (MCQ) Networking Online Earning Online IT Jobs Operating System Oracle Forms and Reports Programming Guide Programming Language SEO Social Networking Sites Software Download Software Engineering System Analysis and Design Top List VB.Net
false
rtl
item
Max6: Write a Program in C to Find if a Number is Present in a List or not
Write a Program in C to Find if a Number is Present in a List or not
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3kSQHkxX799RMvcMUq-jpa0yMk_GdwwV9GAxfQKqhc-4LwVgYfwSMntDcZL5PfgjljINH6WIRka_7QGH78neQNZnjrgpPxh01Wl10BmYb2k_3fDlBlXKUmDqUV4zuT_mz-Y9mnPKC3bhV/s1600/search.PNG
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3kSQHkxX799RMvcMUq-jpa0yMk_GdwwV9GAxfQKqhc-4LwVgYfwSMntDcZL5PfgjljINH6WIRka_7QGH78neQNZnjrgpPxh01Wl10BmYb2k_3fDlBlXKUmDqUV4zuT_mz-Y9mnPKC3bhV/s72-c/search.PNG
Max6
https://maxs29.blogspot.com/2014/07/write-program-in-c-to-find-if-number-is.html
https://maxs29.blogspot.com/
http://maxs29.blogspot.com/
http://maxs29.blogspot.com/2014/07/write-program-in-c-to-find-if-number-is.html
true
4303790511137642940
UTF-8
لم يتم العثور على اى مواضيع شاهد الكل اقرأ المزيد رد احذف الرد حذف بواسطة الرئيسية صفحات مواضيع شاهد الكل نوصى لك التسميات الارشيف بحث لم يتم العثور على ماتبحث عنه عودة للرئيسية الاحد الاثنين الثلاثاء الاربعاء الخميس الجمعة السبت الاحد الاثنين الثلاثاء الاربعاء الخميس الجمعة السبت يناير فبراير مارس ابريل مايو يونيو يوليو اغسطس سبتمبر اكتوبر نوفمبر ديسمبر يناير فبراير مارس ابريل مايو يونيو يوليو اغسطس سبتمبر اكتوبر نوفمبر ديسمبر just now 1 دقيقة مضت $$1$$ دقيقة مضت 1 hour ago $$1$$ ساعة مضت الامس $$1$$ يوم مضى $$1$$ اسبوع مضى اكثر من 5 اسابيع مضت