WISH YOU A VERY HAPPY NEW YEAR

C PROGRAM

                      1) Hello world in C language

//C hello world example
#include <stdio.h>

int main()
{
  printf("Hello world\n");
  return 0;
}

                   2) Add two numbers in C language

 
#include<stdio.h>

int main()
{
   int a, b, c;

   printf("Enter two numbers to add\n");
   scanf("%d%d",&a,&b);

   c = a + b;

   printf("Sum of entered numbers = %d\n",c);

   return 0;
}

         3) Addition, subtraction, multiplication and division in C 

#include <stdio.h>
 int main()
{
   int first, second, add, subtract, multiply;
   float divide;
   printf("Enter two integers\n");

   scanf("%d%d", &first, &second);
   add        = first + second;
   subtract = first - second;
   multiply = first * second;
   divide     = first / (float)second;  
   printf("Sum = %d\n",add);
   printf("Difference = %d\n",subtract);
   printf("Multiplication = %d\n",multiply);
   printf("Division = %.2f\n",divide);
   return 0;
}

                  4) c program to check odd or even

#include<stdio.h>
 main()
{
   int n;
   printf("Enter an integer\n");
   scanf("%d",&n);
   if ( n %2 ==0 )
   printf("Even\n");
   else
   printf("odd\n");
   return 0;
}
 
 

          5) check whether input alphabet is a vowel or not

#include <stdio.h>
 int main()
{
  char ch;
  printf("Enter a character\n");
  scanf("%c", &ch);
  if (ch == 'a' || ch == 'A' || ch == 'e' || ch == 'E' || ch == 'i' || ch  == 'I' || ch =='o' || ch=='O' || ch == 'u' || ch == 'U')

   printf("%c is a vowel.\n", ch);
else
  printf("%c is not a vowel.\n", ch);
  return 0;
}

   

 

No comments:

Post a Comment