Archive Pages Design$type=blogging

C Program to Read Set of Real Numbers from Keyboard & Find the Maximum

To write a C program to read set of real numbers from keyboard and find the maximum among them, you can use a function which takes an array...


C Program to Read Set of Real Numbers and Find the Maximum
To write a C program to read set of real numbers from keyboard and find the maximum among them, you can use a function which takes an array of real numbers and its size as arguments and return the maximum.


Using this function you can write a program to read a set of real numbers from the keyboard and find the maximum number in the array.






C Program to Read Set of Real Numbers and Find the Maximum



Steps: 
  1. Define a function max() 
  2. Under main() function, declare two integers i and n.
  3. Declare an array a.
  4. Prompt the message to the user to insert how many elements they want to enter using printf() and allow to enter using scanf().
  5. Prompt the message and allow to enter the elements.
  6. Find out the maximum number among them using max() function.
  7. Print the maximum number along with message.

Code:


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

max(float a[], int n);

void main()
{

int i,n;
float a[100];


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

printf("\n Enter the elements:");
for(i=0;i<n;i++)
scanf("%f",&a[i]);
max(a,n);
getch();
}

max(float a[], int n)

{
int i;
float k, large;
large=a[0];
for (i=1;i<n;i++)
{
if (a[i]>large)
{
k=a[i];
a[i]=large;
large=k;
}
}

printf("Largests element is : %f", large);

return 0;

}


 

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: C Program to Read Set of Real Numbers from Keyboard & Find the Maximum
C Program to Read Set of Real Numbers from Keyboard & Find the Maximum
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh8ss64wNfrm6FWgK7_p_vV2hhTGjxQkihPnOVcMQjweEQR2jaBMMpwf5mjLKKJfBANd4n2bC12yWJgdQUj5zQckhYZFhftWJhMD5jR7t0MNl_JD9Gp8e9am7qPwPm1gQToliX08_CdCpqZ/s1600/c-max-function.PNG
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh8ss64wNfrm6FWgK7_p_vV2hhTGjxQkihPnOVcMQjweEQR2jaBMMpwf5mjLKKJfBANd4n2bC12yWJgdQUj5zQckhYZFhftWJhMD5jR7t0MNl_JD9Gp8e9am7qPwPm1gQToliX08_CdCpqZ/s72-c/c-max-function.PNG
Max6
https://maxs29.blogspot.com/2014/07/c-program-to-read-set-of-real-numbers.html
https://maxs29.blogspot.com/
http://maxs29.blogspot.com/
http://maxs29.blogspot.com/2014/07/c-program-to-read-set-of-real-numbers.html
true
4303790511137642940
UTF-8
لم يتم العثور على اى مواضيع شاهد الكل اقرأ المزيد رد احذف الرد حذف بواسطة الرئيسية صفحات مواضيع شاهد الكل نوصى لك التسميات الارشيف بحث لم يتم العثور على ماتبحث عنه عودة للرئيسية الاحد الاثنين الثلاثاء الاربعاء الخميس الجمعة السبت الاحد الاثنين الثلاثاء الاربعاء الخميس الجمعة السبت يناير فبراير مارس ابريل مايو يونيو يوليو اغسطس سبتمبر اكتوبر نوفمبر ديسمبر يناير فبراير مارس ابريل مايو يونيو يوليو اغسطس سبتمبر اكتوبر نوفمبر ديسمبر just now 1 دقيقة مضت $$1$$ دقيقة مضت 1 hour ago $$1$$ ساعة مضت الامس $$1$$ يوم مضى $$1$$ اسبوع مضى اكثر من 5 اسابيع مضت