Docsity

C Programming: Finding Maximum, Checking Sign and Even Odd Numbers, Lab Reports of Programming Languages

Partial preview of the text

Download C Programming: Finding Maximum, Checking Sign and Even Odd Numbers and more Lab Reports Programming Languages in PDF only on Docsity!

1.Write a C program to find maximum between two numbers.

#include <stdio.h> int main() { int num1,num2; printf("Enter two numbers:\n"); scanf("%d%d",&num1,&num2); if(num1>num2) printf("%d is a maximum number\n",num1); else printf("%d is a maximum number\n",num2); return 0;

2.Write a C program to check whether a number is negative, positive or zero.

#include <stdio.h> int main() { int a; printf("Enter a number: \n "); scanf("%d", &a); if (a > 0) printf("%d is positive.", a); else if (a < 0) printf("%d is negative.", a); else if (a == 0) printf("%d is zero. \n", a); return 0;