diff --git a/1stint.c b/1stint.c index cbfe4f4..a0da623 100644 --- a/1stint.c +++ b/1stint.c @@ -1,6 +1,13 @@ #include int main() { - int no = 20; - printf ("The value is %d",no); + int no; + printf("Enter a number: "); + scanf("%d",&no); + if(no < 0) + printf("Invalid no.!!!"); + else{ + printf ("The value is %d",no); + } + return 0; } diff --git a/Addition b/Addition new file mode 100644 index 0000000..c1caf6a --- /dev/null +++ b/Addition @@ -0,0 +1,9 @@ +#include +int main(void) { + int a = 545; + int b = 123; + printf("The first number is %d and the second number is %d \n", a , b); + int sum = a + b; + printf("The sum of two numbers is %d" , sum); + return 0; +} diff --git a/even.c b/even.c new file mode 100644 index 0000000..88dbcc1 --- /dev/null +++ b/even.c @@ -0,0 +1,14 @@ +#include + +int main() { + int i; + printf("Even numbers between 1 to 50 (inclusive):\n"); + for (i = 1; i <= 10; i++) + { + if(i%2 == 0) + { + printf("%d ", i); + } + } + return 0; +} diff --git a/greatestnumber.c b/greatestnumber.c new file mode 100644 index 0000000..25da7fd --- /dev/null +++ b/greatestnumber.c @@ -0,0 +1,25 @@ +#include +int main() + +{ + +int ch=3; + +switch(ch) + +{ + +default: printf(“Default”); + +case 1: printf(“option1”); break; + +case 2: printf(“option2”); break; + +} + +return 0; + +} + + +