C Programe
C Programe
----------------------------------------------------------------------------------------------------------#include<stdio.h> main() { int a; printf("Enter an integer\n"); scanf("%d", &a); printf("Integer that you have entered is %d\n", a); } return 0;
#include<stdio.h> #include<conio.h> main() { int a, b, c; printf("Enter two numbers to add "); scanf("%d%d",&a,&b); c = a + b; printf("Sum of entered numbers = %d\n",c); getch(); return 0; } #include<stdio.h> #include<conio.h> main() { int first, second, add, sub, mul, div; printf("Enter two numbers "); scanf("%d%d",&first,&second); add sub mul div = = = = first first first first + * / second; second; second; second;
printf("Multiplication of two numbers = %d\n",mul); printf("Division of two numbers = %d",div); getch(); return 0;
} #include<stdio.h> main() { char ch; printf("Enter a character\n"); scanf("%c",&ch); switch(ch) { case 'a': case 'A': case 'e': case 'E': case 'i': case 'I': case 'o': case 'O': case 'u': case 'U': printf("%c is a vowel.\n", ch); break; default: printf("%c is not a vowel.\n", ch); } return 0; }
#include<stdio.h> main() { int year; printf("Enter a year to check if it is a leap year\n"); scanf("%d", &year); if ( year%400 == 0) printf("%d is a leap year.\n", year); else if ( year%100 == 0) printf("%d is not a leap year.\n", year); else if ( year%4 == 0 ) printf("%d is a leap year.\n", year); else printf("%d is not a leap year.\n", year); return 0; } #include<stdio.h> #include<conio.h> main() { int num, sum = 0, rem; printf("Enter a number\n"); scanf("%d",&num); while( { rem sum num } num != 0 ) = num % 10; = sum + rem; = num / 10;