





























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
A comprehensive overview of the fundamental concepts and techniques in c programming. It covers various data types, operators, control structures, and functions in the c language. The document aims to serve as a valuable resource for students and learners who are new to c programming or looking to deepen their understanding of the language. It includes detailed explanations, code examples, and exercises to reinforce the concepts. By studying this document, users can gain a solid foundation in c programming and be well-equipped to tackle more advanced topics and projects.
Typology: Study notes
1 / 37
This page cannot be seen from the preview
Don't miss anything!
#include <stdio.h> int main(){ int a,b; printf("Enter an integer value for variable a : "); scanf("%d ",&a); printf("\nEnter an integer value for variable b : "); scanf("%d ",&b); //Arithmetic Operators printf("\nPlus(+) operator : a+b = %d",a+b); printf("\nMinus(-) operator : a-b = %d",a-b); printf("\nMultiply() operator : ab = %d",ab); printf("\nDivide(/) operator : a/b = %d",a/b); printf("\nModulus(%) operator : a%b = %d",a%b); printf("\nUnary Plus(+) operator : +a = %d",+a); printf("\nUnary Minus(-) operator : -b = %d",-b); printf("\nPost Increment(++) operator : a++ = %d",a++); printf("\nPre Increment(++) operator : ++a = %d",++a); printf("\nPost Decrement(--) operator : b-- = %d",b--); printf("\nPre Decrement(--) operator : --b = %d",--b); //Relational Operators printf("\nLess than or equal to(<=) : a<=b = %d",a<=b); printf("\nGreater than or equal to(>=) : a>=b = %d",a>=b); printf("\nLess than(<) : a<b = %d",a<b); printf("\nGreater than(>) : a>b = %d",a>b); printf("\nEqual to(==) : a==b = %d",a==b); printf("\nNot Equal to(!=) : a!=b = %d",a!=b); //Logical Operators printf("\nLogical AND(&&) : (a>b)&&(b!=a) = %d",(a>b)&&(b!=a)); printf("\nLogical OR(||) : (a>b)||(b!=a) = %d",(a>b)||(b!=a)); printf("\nLogical NOT(&&) : !(a>b) = %d",!(b!=a)); //Bitwise Operators printf("\nBitwise AND(a&b) : %d", a&b); printf("\nBitwise OR(a|b) : %d", a|b); printf("\nBitwise XOR(a^b): %d", a^b); printf("\nBitwise First Compliment(~a): %d", ~a); printf("\nBitwise Right Shift(a>>b): %d", a>>b); printf("\nBitwise Left Shift(a<<b): %d", a<<b); //Assignment Operators printf("\nSimple Assignment Operator(a=b) : %d", a=b); printf("\nPlus and Assignment Operator(a+=b) : %d", a+=b); printf("\nMinus and Assignment Operator(a-=b) : %d", a-=b); printf("\nMultiply and Assignment Operator(a= b) : %d", a*=b); printf("\nDivide and Assignment Operator(a/=b): %d", a/=b); printf("\nModulus and Assignment Operator(a%=b) : %d", a%=b); printf("\nAND and Assignment Operator(a&=b) : %d", a&=b); printf("\nOR and Assignment Operator(a|=b) : %d", a|=b); printf("\nRight Shift Assignment Operator(a>>=b) : %d", a>>b); printf("\nLeft Shift Assignment Operator(a<<=b) : %d", a<<b); }
C Program to demonstrate Data Types in C #include <stdio.h> int main(){ in t a; printf("Enter an integer value for variable a : "); scanf("%d ",&a); float f; printf("\nEnter an float value for variable f : "); scanf("%f ",&f); char c; printf("\nEnter a character value for variabe c : "); scanf("%c",&c); double d; printf("\nEnter a double value for variable d : "); scanf("%lf ",&d); short int e; printf("\nEnter a short int value for variable e : "); scanf("%hd ",&e); unsigned short int g; printf("\nEnter an unsigned short int value for variable g : "); scanf("%hu ",&g); unsigned int h; printf("\nEnter an unsigned int value for variable h : "); scanf("%u",&h); long int i; printf("\nEnter a long int value for variable i : "); scanf("%ld ",&i); unsigned long int j; printf("\nEnter an unsigned long int value for variable j : "); scanf("%lu ",&j); long long int k; printf("\nEnter a long long int value for variable k : "); scanf("%lld ",&k); unsigned long long int l; printf("\nEnter a unsigned long long int value for variable l : "); scanf("%llu ",&l); signed char m; printf("\nEnter a signed char value for variable m : "); scanf("%c ",&m); unsigned char y; printf("\nEnter a unsigned char value for variable y : "); scanf("%c ",&y); long double z; printf("\nEnter a long double value for variable z : "); scanf("%Lf ",&z); int sizeint = sizeof(int); int sizechar = sizeof(char); int sizefloat = sizeof(float); int sizedouble = sizeof(double); printf("\nThe size of int data type : %d", sizeint); printf("\nThe size of char data type : %d",sizechar); printf("\nThe size of float data type : %d",sizefloat); printf("\nThe size of double data type : %d",sizedouble);
Input : Output :
#include <stdio.h> //Program to calculate electricity bill int main(){ float units; printf("Enter the value of units: "); scanf("%f",&units); if(units>=300){ printf("\nTotal Bill Amount is %.2f",units2.5); } else if(units>300 & units<400){ printf("\nTotal Bill Amount is %.2f",units2.75); } else if(units>400 & units<600){ printf("\nTotal Bill Amount is %.2f",units3.25); } else{ printf("\nTotal Bill Amount is %.2f",units5); } }
#include <stdio.h> //Program to calculate income tax int main(){ float income; printf("Enter the value of income : "); scanf("%f",&income); if(income>=100000){ printf("\nTax Amount to be paid is %.2f",income0.05); } else if(income>100000 & income<=150000){ printf("\nTax Amount to be paid is %.2f",income0.075); } else if(income>150000 & income<300000){ printf("\nTax Amount to be paid is %.2f",income0.10); } else{ printf("\nTax Amount to be paid is %.2f",income0.18); } }
#include <stdio.h> //Program to calculate Odd or even number int main(){ int number; printf("Enter the number : "); scanf("%d",&number); if(number%2 == 0){ printf("\n%d is an even number",number); } else{ printf("\n%d is an odd number",number); } }
- K.Saipavan ,21BEC
- K.Saipavan , 21BEC