Semester : S1 and S2
Subject : Computer Programming
Year : 2018
Term : MARCH
Branch : BIOTECHNOLOGY
Scheme : 2015 Full Time
Course Code : CS 100
Page:4
double number, sum = 0.0;
for(i=1; i <= 10; ++i)
{
printf("E a n%d: ",i);
scanf("%lf",&number);
// \f user enters negative number, loop is terminated
if(number < 0.0)
{
sum += number; // sum = sum + number;
printf("Sum = %.2If",sum);
break; }
return 0;
}
Output
Enter 311: 2.4
Enter 312: 4.5
Enter 313: 3.4
Enter a :4م -3
Sum = 10.30
2. scanf() and printf() functions functions printf() and scanf(), which are used to display output
on screen and to take
input from user respectively.In general terms, the scanf function is written as:
scanf(control string, 3181, arg2,......... வதிய
where control string refers to a string containing certain required formatting information, and
arg1,arg2,....,argN are arguments that represent the individual data items.
getchar() & putchar() functions