Archive Pages Design$type=blogging

C Program to Find the Sum and Average of Numbers Using Do-While Loop

In this program sum and average of of the given numbers are calculated using do-while loop. Do-while loop is a looping condition where state...


C Program to Find the Sum and Average of Numbers Using Do-While Loop
In this program sum and average of of the given numbers are calculated using do-while loop.

Do-while loop is a looping condition where statements are executed continuously until the condition validates and test the condition after having executed the statements within the loop.

This means that do-while would execute its statements at least once, even if the condition fails for the first time.
 
Scanf() command is used here to allow enter the numbers and sum=sum+num; to sum the numbers within do-while loop.



C Program to Find the Sum and Average of Numbers Using Do-While Loop



Steps: 
  1.  Declare two integers i and n and also initialize i with 0.
  2. Declare three floats sum, avg and num and initialize sum with 0.
  3. Print the message on the screen to enter how many numbers want to find sum.
  4. Use do-while loop to insert the numbers calculate the sum and average.




Code:




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



void main()
{

int i=0,n;
float sum, avg, num;

clrscr();

sum=0;

printf("How many numbers you want to find sum and average\n");
scanf("%d",&n);

printf("Enter the numbers\n");

do{
scanf("%f", &num);
sum=sum+num;
i++;
}

while (i<n);

avg=sum/n;

printf("Sum=%f\n", sum);
printf("Average=%f\n", avg);
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
Max5: C Program to Find the Sum and Average of Numbers Using Do-While Loop
C Program to Find the Sum and Average of Numbers Using Do-While Loop
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhb7SNMOoqR0RJjDDyEbqJT_-LE_xVEWYcRTWsaCO0fAahNKKLpJIPgPxBVKnI3LOV4KNMrTsdb4kSNcuTNnFKZF5PSmCaHYh888uTXHM8I0R-JDZpe3zzhWdfFuK5pmXphcTggJuz7rGk0/s1600/sum-avg.PNG
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhb7SNMOoqR0RJjDDyEbqJT_-LE_xVEWYcRTWsaCO0fAahNKKLpJIPgPxBVKnI3LOV4KNMrTsdb4kSNcuTNnFKZF5PSmCaHYh888uTXHM8I0R-JDZpe3zzhWdfFuK5pmXphcTggJuz7rGk0/s72-c/sum-avg.PNG
Max5
https://maxs27.blogspot.com/2014/07/c-program-to-find-sum-and-average-of.html
https://maxs27.blogspot.com/
http://maxs27.blogspot.com/
http://maxs27.blogspot.com/2014/07/c-program-to-find-sum-and-average-of.html
true
1760660989564394152
UTF-8
لم يتم العثور على اى مواضيع شاهد الكل اقرأ المزيد رد احذف الرد حذف بواسطة الرئيسية صفحات مواضيع شاهد الكل نوصى لك التسميات الارشيف بحث لم يتم العثور على ماتبحث عنه عودة للرئيسية الاحد الاثنين الثلاثاء الاربعاء الخميس الجمعة السبت الاحد الاثنين الثلاثاء الاربعاء الخميس الجمعة السبت يناير فبراير مارس ابريل مايو يونيو يوليو اغسطس سبتمبر اكتوبر نوفمبر ديسمبر يناير فبراير مارس ابريل مايو يونيو يوليو اغسطس سبتمبر اكتوبر نوفمبر ديسمبر just now 1 دقيقة مضت $$1$$ دقيقة مضت 1 hour ago $$1$$ ساعة مضت الامس $$1$$ يوم مضى $$1$$ اسبوع مضى اكثر من 5 اسابيع مضت