Advertisement
rafikamal

Structure With Multiple Variables

Jan 27th, 2013
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.44 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. struct new_struct
  4. {
  5.     int i;
  6.     char ch;
  7.     double d;
  8.     char str[80];
  9. };
  10.  
  11. int main()
  12. {
  13.     new_struct s;
  14.  
  15.     printf("Enter an integer: ");
  16.     scanf("%d",&s.i);
  17.     printf("Enter a double: ");
  18.     scanf("%lf",&s.d);
  19.     getchar();
  20.     printf("Enter a character: ");
  21.     s.ch = getchar();
  22.     getchar();
  23.     printf("Enter a string: ");
  24.     gets(s.str);
  25.  
  26.     printf("%d %f %c %s",s.i,s.d,s.ch,s.str);
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement