Skip to content

Instantly share code, notes, and snippets.

@RezaBidar
Created April 27, 2015 06:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RezaBidar/4df29475cd783376052c to your computer and use it in GitHub Desktop.
Save RezaBidar/4df29475cd783376052c to your computer and use it in GitHub Desktop.
gist for Davood Mirzaei ; run in dev c++ in C language
#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