on
Italy
- Get link
- X
- Other Apps
goto label; ............. ............. ............. label: statement;
label: and executes the code below it.
/* C program to demonstrate the working of goto statement. */
/* This program calculates the average of numbers entered by user. */
/* If user enters negative number, it ignores that number and
calculates the average of number entered before it.*/
# include
int main(){
float num,average,sum;
int i,n;
printf("Maximum no. of inputs: ");
scanf("%d",&n);
for(i=1;i<=n;++i){
printf("Enter n%d: ",i);
scanf("%f",&num);
if(num<0 .0="" 0="" average="" code="" control="" f="" goto="" jump:="" jump="" label="" moves="" of="" printf="" program="" return="" sum="sum+num;" the="" to="" verage:="">0>
Maximum no. of inputs: 4 Enter n1: 1.5 Enter n2: 12.5 Enter n3: 7.2 Enter n4: -1 Average: 7.07
Comments
Post a Comment