Programs on arrays in C

One Dimensional Array /* Author : ITVoyagers (https://itvoyagers.in/) Date :25th December 2018 Description : One Dimensional Array. */ #include <conio.h> #include <stdio.h> void main() { int a[10],c; char n[]=”myname”;// or char n[]={‘m’,’y’,’n’,’a’,’m’,’e’}; clrscr(); printf(“Enter 10 number in array: “); for(c=0;c<10;c++) { scanf(” %d \n”,&a[c]); } printf(“print integer array \n”); for(c=0;c<10;c++) { printf(“%d \n”,a[c]); } printf(“Enter … Read more

Programs on looping in C

while loop /* Author : ITVoyagers (https://itvoyagers.in/) Date :25th December 2018 Description : While loop. */ #include<stdio.h> void main() { int r=0; while(r<5) { printf(“%i\n”,r); r++; } } Output: 0 1 2 3 4 do-while loop /* Author : ITVoyagers (https://itvoyagers.in/) Date :25th December 2018 Description : do-While loop. */ #include<stdio.h> void main() { int … Read more

Decision Statement in C

Decision Statement (if statement) /* Author : ITVoyagers (https://itvoyagers.in/) Date :25th December 2018 Description : Decision Statement (if statement). */ #include<stdio.h> void main() { int a; printf(“Enter a number: “); scanf(“%d”,&a); if(a>0) { printf(“It is positive number”); } } Output: Enter a number: 5 It is positive number Decision Statement (if-else statement) /* Author : … Read more

Programs on Operators and Expressions in C

/* Author : ITVoyagers (https://itvoyagers.in/) Date :25th December 2018 Description : Programs on Operators and Expressions. */ #include<stdio.h> #include<conio.h> void main() { int a=5,b=3,*p; p=&a; clrscr(); /************ Unary Operators ***********/ printf(“\nUnary Operators\nOperators that operates or works with a single operand are unary operators. For example: (++ , –)\n”); printf(“\nBitwise Complement ~a=%d”,~a); printf(“\nUnary Minus -a=%d”,-a); printf(“\nPointer … Read more

Programs to understand the basic data types and I/O in C.

basic.c /* Author : ITVoyagers (https://itvoyagers.in/) Date :25th December 2018 Description : Programs to understand the basic data types and I/O. */ #include<stdio.h> void main() { int i; char c; float f; double d; char s[10]; //string /********* Printing size of Datatypes **********/ printf(“size of number: %d \n”,sizeof(int)); printf(“size of character: %d \n”,sizeof(char)); printf(“size of … Read more