Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main(){
- int a,b;
- printf("Enter two numbers: ");
- scanf("%d %d", &a, &b);
- printf("\nSum:%d ", a+b);
- return 0;
- }
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////
- #include <stdio.h>
- int main() {
- int x;
- float num;
- char text[20];
- scanf("%d %f %s", &x, &num, text);
- //Typing 10 22.5 abcd and then pressing Enter assigns 10 to x, 22.5 to num, and abcd to text.
- }
- //////////////////////////////////////////////////////////////////////////////////////////////////////////////
- #include <stdio.h>
- int main() {
- printf("Color: %s, Number: %d, float: %5.2f \n", "red", 42, 3.14159);
- /* Color: red, Number: 42, float: 3.14 */
- printf("Pi = %3.2f \n", 3.14159);
- /* Pi = 3.14 */
- printf("Pi = %8.5f \n", 3.14159);
- /* Pi = 3.14159 */
- printf("Pi = %-8.5f \n", 3.14159);
- /* Pi = 3.14159 */
- printf("There are %d %s in the tree. \n", 22, "apples");
- /* There are 22 apples in the tree. */
- }
- /////////////////////////////////////////////////////////////////////////////////////////////////////////////
- #include <stdio.h>
- int main(){
- int a;
- printf("Enter a number: ");
- scanf("%d", &a);
- printf("\nThe number you entered is: %d", a);
- if (a > 4)
- printf("\nThe number is bigger than four");
- else
- printf("\nThe number is less than four");
- return 0;
- }
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- #include <stdio.h>
- int SumOfNumbers(int a, int b){
- int sum;
- sum = a + b;
- return sum;
- }
- int main(){
- int a,b;
- printf("Enter two numbers: ");
- scanf("%d %d", &a, &b);
- int sum = SumOfNumbers(a,b);
- printf("%d\n", sum);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement