C programing General Preprocessing items: Use mnemonic variables of 3 characters
ID: 643845 • Letter: C
Question
C programing
General Preprocessing items: Use mnemonic variables of 3 characters or more. Use void main (void) or void main ( ) in your program and leave off the return 0. Use double as the choice for all floating point values. Add heading items using as printf statement. Watch for instructions that specify a symbolic constant and assign that symbolic constant in all capital letters and using the #define
C programing General Preprocessing items: Use mnemonic variables of 3 characters or more. Use void main (void) or void main ( ) in your program and leave off the return 0. Use double as the choice for all floating point values. Add heading items using as printf statement. Watch for instructions that specify a symbolic constant and assign that symbolic constant in all capital letters and using the #define Problem 1: Make a computerized flow chart that represents a program that prompts the user to enter an integer quantity and then prompts the user for that quantity of floating point numbers. The program may accept positive or negative numbers. As the numbers are read into the program, the program should verify positive or negative number and the program will calculate the average of the negative numbers. The program should also note the sequence and quantity of the negative numbers entered by performing operations to fill in the bold / shaded areas with calculated values. The count does not increase until a negative number is entered. The average should be shown with 3 decimal places. The program is required to use Prefix increment/decrement and or Postfix increment/decrement where applicable. The program is required to use Compound assignment / compound expressions where applicable.Explanation / Answer
#include
#include
void main()
{
int a,i;
double ar[7];
double add,c,chk;
clrscr();
printf(" Enter quantity of negative no u want to avg:");
scanf("%d",&a);
for(i=0;i<=a-1;i++)
{
printf(" Enter no. %d",i+1);
scanf("%lf",&chk);
if(chk>=0)
{
printf(" Pl. enter negative value");
i--;
}
else
{
ar[i] = chk;
}
}
for (i=0;i<=a-1;i++)
{
add=add+ar[i];
}
c=add/a;
printf("The Average of %d numbers is %lf",a,c);
printf(" Press any key to Continue");
getch();
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.