Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8492127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T22:37:45+00:00 2026-06-10T22:37:45+00:00

This program is calculating average in whole number without printing decimal values. It prints

  • 0

This program is calculating average in whole number without printing decimal values. It prints the result as a whole number: N.000000. Why?

//Store name, roll no, marks of 4 students using structure
//and calculating average
struct student
{
    char name[10];
    int roll_no;
    int marks;
};

void main()
{
    struct student s1,s2,s3,s4;
    float avg;
    clrscr();
    printf("\nEnter name, rollnumber and marks of student 1 : \n");
    scanf("%s%d%d",&s1. name,&s1. roll_no,&s1. marks);
    printf("\nEnter name, rollnumber and marks of student 2 : \n");
    scanf("%s%d%d",&s2. name,&s2. roll_no,&s2. marks);
    printf("\nEnter name, rollnumber and marks of student 3 : \n");
    scanf("%s%d%d",&s3. name,&s3. roll_no,&s3. marks);
    printf("\nEnter name, rollnumber and marks of student 4 : \n");
    scanf("%s%d%d",&s4. name,&s4. roll_no,&s4. marks);
    avg = (s1. marks + s2. marks + s3. marks + s4. marks) / 4;
    printf("\nAverage : %f",avg);

    getch();
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T22:37:47+00:00Added an answer on June 10, 2026 at 10:37 pm
    int marks;
    

    means that each mark is an integer. Then you sum them, that’s also an integer. Then you divide them by 4, that’s also an integer, so this operation will be an integer division – an operation that throws away the fractional part of the result. Divide it by 4.0 instead and you’ll be fine to go.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a program for calculating factorial of a number and I store it
This program stores pairs in a map, counting the number of times a word
I'm very new to programming and for some reason this program is not calculating
My code is pasted below.When I run this program,it keeps on calculating.I am using
Actually I wrote a Java program for calculating a particular number on the Fibonacci
I'm using Task Parallel Library (TPL ) for calculating Fibonacci number. Program is given
I wrote a simple program(calculating the number of steps for the numbers 1-10^10 using
This program builds a dictionary out of a list based on what two index
This program returns: package main import ( flag fmt ) func main() { num_agents
This program runs just fine, but for some reason when I ask for an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.