KEMBAR78
Conditional Statement For C | PDF
0% found this document useful (0 votes)
26 views2 pages

Conditional Statement For C

The document contains code for a C program that calculates the total and average of 5 scores entered by the user. It uses a do-while loop to repeatedly get scores until valid scores between 50-100 are entered up to 3 times.

Uploaded by

vipul21
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views2 pages

Conditional Statement For C

The document contains code for a C program that calculates the total and average of 5 scores entered by the user. It uses a do-while loop to repeatedly get scores until valid scores between 50-100 are entered up to 3 times.

Uploaded by

vipul21
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

#include <stdio.

h>

#include <stdlib.h>

int main(void)

double score1=0.0,score2=0.0,score3=0.0,score4=0.0,score5=0.0,total,average;

int count=0;

//printf("Enter 5 scores:\n");

//scanf("%lg %lg %lg %lg %lg", &score1,&score2,&score3,&score4,&score5);

do{

printf("Enter 5 scores:\n");

scanf("%lg %lg %lg %lg %lg", &score1,&score2,&score3,&score4,&score5);

count=count+1;

//printf("Good Bye !!!!!!!!:\n");

}while ((score1 > 100.0 || score1 <50.0 || score2 > 100.0 || score2 <50.0 || score3> 100.0 || score3
<50.0 || score4> 100.0 || score4 <50.0 || score5> 100.0 || score5 <50.0)&& (count <3 )); // define as a
constant for better

if ((score1 < 100.0 && score1 >50.0) && (score2 < 100.0 && score2 >50.0) && (score3< 100.0 &&
score3 >50.0) && (score4< 100.0 && score4 >50.0) && (score5< 100.0 && score5 >50.0) )

total=score1+score2+score3+score4+score5;

average=total/5;

printf("total score is %g " ,total);

printf("average is is %g " ,average);

//break;

else
printf("Good Bye !!!!!!!!:\n");

return 0;

You might also like