Created
April 27, 2015 06:00
-
-
Save RezaBidar/4df29475cd783376052c to your computer and use it in GitHub Desktop.
gist for Davood Mirzaei ; run in dev c++ in C language
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
/* run this program using the console pauser or add your own getch, system("pause") or input loop */ | |
int main(int argc, char *argv[]) { | |
int counter = 1 ; | |
char fname[50] , lname[50] , address[100] , shenasname[20]; | |
float weight , height , w_sum = 0, h_sum = 0; | |
while(counter>0){ | |
puts("Fisrt Name : "); | |
scanf("%s" , fname); | |
if(strcmp(fname , "Control_Z") == 0) break ; | |
puts("Last Name : "); | |
scanf("%s" , lname); | |
getchar(); | |
puts("Address : "); | |
gets(address); | |
puts("Shenasname : "); | |
scanf("%s" , shenasname); | |
do{ | |
puts("Weight : "); | |
scanf("%f" , &weight); | |
}while(weight < 20 || weight > 200); | |
do{ | |
puts("Height : "); | |
scanf("%f" , &height); | |
}while(height < 30 || height > 180); | |
w_sum += weight ; | |
h_sum += height ; | |
printf("%-12s : %05d\n", "Number" , counter); | |
printf("%-12s : %s %s\n", "Name" , fname , lname); | |
printf("%-12s : %s\n", "Address" , address); | |
printf("%-12s : %s\n", "Shenasname" , shenasname); | |
printf("%-12s : %.1f\n", "Weight" , weight); | |
printf("%-12s : %.1f\n", "Height" , height); | |
printf("%-12s : %.1f\n", "Ave Weight" , w_sum/counter); | |
printf("%-12s : %.1f\n\n", "Ave Height" , h_sum/counter); | |
puts("agar karbare digari nadarid Control_Z ra vared namaiid \n"); | |
counter++ ; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment