Guest User

Untitled

a guest
Dec 12th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.65 KB | None | 0 0
  1. #include<stdio.h> //library of output and input functions
  2. #include<conio.h> //library of screen cleaning and other service
  3. #include<math.h> //library of mathematical functions
  4. #include<iostream>
  5. using namespace std;
  6.  
  7. void main()
  8. { // main function - entry point to the programm
  9. char simbol;
  10. puts("function puts():"); //displaying the message on the screen
  11. puts("input symbol"); //displaying the message on the screen
  12. putchar(getch()); //output the symbol, what doesn't display during the entering
  13. puts("\n repeat input symbol-function getch():"); //output the message
  14. simbol=getch(); //input symbol from the keyboard
  15. putchar(simbol); //output symbol on the screen
  16.  
  17. char str[20];
  18. puts("\n input string -function gets():"); //output te message on the screen
  19.  
  20. gets(str); //input string
  21. printf("functions printf(),puts(): str="); //formatted output
  22. puts(str); //output string
  23. printf("\r\n function printf(): str=%s \r\n",str); //formatted output string
  24.  
  25. int i;
  26. double a,b,c,d;
  27.  
  28. puts("function scanf(),printf()");
  29. printf("\n input integer i, double a,b,c \n"); // formatted output
  30. scanf("%i%d%d%d",&i,&a,&b,&c); //formatted input
  31. printf("i=%i a=%d b=%d c=%d", i,a,b,c); //formatted output
  32. puts("\n input string for sscanf() as %d %f %f or sprintf()");
  33.  
  34. char str1[40],str2[40];
  35. float a1,b1;
  36. fflush(stdin); // cleaning the keyboard buffer
  37.  
  38. gets(str1); //input string from keyboard
  39. printf("string is: ");
  40. puts(str1);
  41. sscanf(str1,"&d %f %f", &i, &a1, &b1); // input from string to the addresses of variables
  42. printf("i=%i a=%f b=%e\n",i,a1,b1); //output on the screen
  43. puts("function sprintf() does not display rezult");
  44. sprintf(str2,"i=%d a=%f b=%e",i,a1,b1); // output into the string
  45. puts("function puts():");
  46. puts(str2);
  47. d=(a-abs(a/b))/(2.75*sin(c)*sin(c));//calculating the expression
  48. puts("function printf():");
  49. printf("d=(a-abs(a/b)/2.75*pow(sin(c),2)=%d",d);
  50.  
  51. char string[30]; //announce the string
  52.  
  53. cout<<"\n input text"<<endl;
  54. cin>>string;
  55. cout<<"entered text is"<<"'"<<string<<"'"<<endl;
  56. fflush(stdin);
  57. getch(); //delay screen
  58.  
  59. }
Add Comment
Please, Sign In to add comment