0% found this document useful (0 votes)
54 views3 pages

C Programe

This document contains C code examples demonstrating basic programming concepts like input/output, arithmetic operations, conditional statements, functions, and loops. The examples include printing "Hello World", reading and writing integers, adding/subtracting/multiplying/dividing two numbers, checking vowels, determining if a year is a leap year, and calculating the sum of digits in a number.

Uploaded by

Sudip Sarkar
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views3 pages

C Programe

This document contains C code examples demonstrating basic programming concepts like input/output, arithmetic operations, conditional statements, functions, and loops. The examples include printing "Hello World", reading and writing integers, adding/subtracting/multiplying/dividing two numbers, checking vowels, determining if a year is a leap year, and calculating the sum of digits in a number.

Uploaded by

Sudip Sarkar
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

#include<stdio.

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

----------------------------------------------------------------------------------------------------------#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("Sum of two numbers = %d\n",add); printf("Difference of two numbers = %d\n",sub);

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; }

Function to check vowel


int check_vowel(char a) { if ( a >= 'A' && a <= 'Z' ) a = a + 'a' - 'A'; /* Converting to lower case */ if ( a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u') return 1; } 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;

printf("Sum of digits of entered number = %d\n",sum); getch(); return 0;

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy