about a program in c language

about a program in c language

Write a program that inputs five different integers from the keyboard, then print the sum, the product, the smallest and the largest of these numbers. Use only single selection form of if statement. For example: 1 3 2 7 4 6 Sum is: 23 Average is: 4.5 Smallest: 1 Largest 7

View Answers

March 31, 2011 at 5:16 PM

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

    int main(void){
      int num = 0;
      int sum = 0;
      int counter = 0;
      int min=0;
      int max=0;
      int temp;
      int product=1;
      while(counter < 5){
      printf("Enter number: ");
      if(scanf("%d", &num) == 1){
      if(num>=max){
         max=num;
      }
      if(num<=temp){
         min=num;
      }
      temp=num;
      sum += num;
      product*=num;
    }
    else{
      fprintf(stderr, "Error!");
      return 0;
    }
    counter++;
  }
  printf("Sum of numbers entered: %d\n", sum);
  printf("Product of numbers entered: %d\n", product);
  printf("The largest number is :%d\n",max);
  printf("The smallest number is :%d",min);

  return 0;
}









Related Tutorials/Questions & Answers:
about a program in c language
about a program in c language   Write a program that inputs five different integers from the keyboard, then print the sum, the product, the smallest and the largest of these numbers. Use only single selection form of if statement
write a program to use for loop print **********========== in c language
write a program to use for loop print **********========== in c language  write a program to use for loop print **========== in c language
Advertisements
Write a C language program to read two matrices and multiply them?
Write a C language program to read two matrices and multiply them?  Write a C language program to read two matrices and multiply them?   Here is an example of multiplying two matrices using C language. #include <
C Language
C Language  What's the right declaration for main()? Is void main() correct? in C language ? please help me sir ! Thank You
C language
C language  i want that when i hit any key only * to be print not the hit key in c language   The given example will display aestricks on hitting any key. #include "stdio.h" #include "conio.h" #include "ctype.h" int
C Language
C Language  Respected sir, Why does sizeof report a larger size than I expect for a structure type, as if there were padding at the end? help me sir
C Language
C Language  Respected Sir, How can I determine the byte offset of a field within a structure? How can I access structure fields by name at run time? please help me sir . Thank you sir
c language code
c language code  Dear Sir, Could you send me the c language codings for BOOK BANK
about c and java
about c and java   i need java and c language interview and objective questions with answers for the fresher.please provide to me   Please...://www.roseindia.net/c-tutorials/ http://www.roseindia.net/interviewquestions
c program
c program  plz send me program for this. write a program to print the following code? (in c language) 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 11 2 3 4 5 6 7 8 9 10
program of c
program of c  write a program in c to display a to z without using printf or scanf statements or header files
c++ program
c++ program  Write a program which reads a text from the keyboard and displays the following information on the screen in two columns: (a) Number of lines (b) Number of words (c) Number of characters Strings should be left
c-language pointer functions
c-language pointer functions  what is the execution process of character pointer functions with example
C Program
C Program  Why doesn't the code int a = 1000, b = 1000; long int c = a * b; work? plz help me sir
c program
c program  How to convert binary digits to decimal number without using power function
c program
c program  WAP to show the area of a perimeter of a rectanglar by using input command
c program
c program  plz send me program for this. write a program to print the following code? 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 11 2 3 4 5 6 7 8 9 10 11 12 3 4
C program
C program  hi, here is my question: Create a structure to specify data on students given below: Roll number, Name,Department, Course, Year... a function to print names of all students who joined in a particular year. (c
about a program
about a program  hi can anyone suggest program for this question.. it wil really be helpful.its based on *servlet programming* 1. First page should display a dropdown of mathematical operation (Add, Subtract, Multiply, Divide
program in c
program in c  Write a program that inputs five different integers from the keyboard, then print the sum, the product, the smallest and the largest of these numbers. Use only single selection form of if statement. For example: 1 3
hotel management programme in c language?
hotel management programme in c language?  hotel management programme in c language
logic for c language
logic for c language  01 02 03 04 05 06 20 21 22 23 24 07 19 32 33 34 25 08 18 31 36 35 26 09 17 30 29 28 27 10 16 15 14 13 12 11
Change case in C language
Change case in C language  I want to right in .dat file through structure.For this i have defined following: struct student //structure defination... If user is typing b5678 ,i want to store as B5678. (C)for input i am using
C Language - Java Beginners
C Language  1. What are extension files? Give examples. 2. What is operating system? What are the different types available? 3. What is the purpose of operating system? 4. What is the function of operating system? 5
method overloading in c program
method overloading in c program  how is method overloading in C program is different from C++ program
malloc in c example program
malloc in c example program  What is malloc in c? Please explain the term using an example in C program. Thanks
C Program with Database Connectivity
C Program with Database Connectivity  How To Connect MySQL Database in C Program with Graphics
C program - SQL
C program  Write a C program for airport simulation using queue data structures. Please reply me
c program - Java Beginners
c program  Write a program to encrypt a string and decrypt
c program - IoC
c program  given the string "wordprocessing",write a program to read the string from the terminal and display the same in the following formats: a) word processing b) word processing c) w.p.
C program to print the following
C program to print the following  Hello, Some one help me with a "C Program" to print the following as output: 4444444 4333334..., that is why I choosed Java Beginners, but please give me a C program
C Program - Development process
C Program  C program to find division of two fraction number without...: #include #include #include int main () { int a; int b; int c; int... in the form a/b: "); scanf("%d/%d", &c, &d); nr=a*d; dr=b*c; printf("%d/%d",nr,dr
c program - Java Beginners
c program  1. How to write a program to Add 2 numbers without using int .size should be more than machine size
C program - Java Magazine
C program  develop a simple program in C that allows a user to enter... and then the program; a)First determines whether the 3 integers entered represent the sides..., the program should print the following; The three integers form a Right-angled
Objective-C keywords
Objective-C keywords       Here in this section we will know about the keywords used in objective-C language. Objective-C is a superset of C language, so program written in c
C program - SQL
C program  write a C program to print multiplication table using pointers.  Hi Friend, Try the following code: #include #include void main() { int i,j; int * pt; clrscr(); printf(" "); printf("\n
C program - SQL
C program  Thank You . Write some C programs using pointers . Write some C programs using files. Please reply me .   Hi Friend, Please visit the following link: http://www.roseindia.net/c
c++ program of inheritance
c++ program of inheritance   Assume that a bank maintains two kinds of accounts for customers, one called as savings account and the other as current.... (b) Display the balance (c) Compute and deposit interest. (d) Permit
C Programming SubString Program
C Programming SubString Program  Sir I want to Check whether the Single Substring is present in the given 3 string. characters. eg if i entered... entered to check PROGRAM is exists in given three strings then output
About running the Applet Program
About running the Applet Program  Hi I have composed an Applet Program and compiled the program, until that it is fine but how to run the Applet program(compiling i typed as javac AppletDemo.java)? Is compiling
About running the Applet Program
About running the Applet Program  Hi I have composed an Applet Program and compiled the program, until that it is fine but how to run the Applet program(compiling i typed as javac AppletDemo.java)? Is compiling
Why Objective C?
; In this section we will learn about the importance of Objective C and "Why Objective C?" is used as programming language to develop applications.... It is a powerful language, 2. Easy-to-learn, 3. Object-oriented version of C, 4
C++ programming language - Java Beginners
C++ programming language  int main() { int i = 1, c = 0, sum = 1,j ; scanf("%d", &j); while (i <= j) { sum = sum + (i /3+i/5); printf
c programming language - Java Beginners
c programming language  int main() { int i = 1, c = 0, sum = 1,j ; scanf("%d", &j); while (i <= j) { sum = sum + (i /3+i/5); printf("%d
C Program....PLEASE HELP
C Program....PLEASE HELP  For this assignment, you are to write a program that calculates points along a rhodonea curve, a.k.a. a mathematical rose, and produces a simple character plot of the results, using functions, arrays
C++ program not running
C++ program not running  Hi, this program need to ask 10 random questions with a random month name. Example: RUN How many days are there in the month of March? 28 No March has 31 days. How many days are there in the month
Objective C Introduction
;  This section provides you the basic introduction about Objective C programming language. Objective C is very old programming language... in early 1980's. The Objective-C language is designed to enable a easier
C Program - Development process
C Program  How to do sum of Diagnol Matrix e.g 3 6 9 4 5 7 7 6 9 I want to display sum of 3+5+9 i.e to do sum of Diagnol Matrix plz Help Me  Hi Friend, Try the following code: #include #include
C program - SQL
C program  Thanks!!!!!!!!!! Please reply me some programs for DATA STRUCTURES (LINKED LISTS,ETC)  Hi Friend, Try the following code: # include # include #include struct element *temp; struct
C language-qsort and bsearch function - Ajax
C language-qsort and bsearch function  Explain qsort and bsearch...() #include #include #include #include char alpha[] = {'a','b','c...); if(p) printf(" %c is in alphabet\n", *p); else printf("is not in alphabet\n

Ads