Author: Alagappan Karthikeyan

Find Two’s Complement of a Binary Number Using C programming

main(){int i,test;char binary[L],dup[L],a[L];void input(char binary[]);int check(char binary[]);void compl(char binary[],char a[]);//clrscr();printf(“Enter Binary no of Maximum Length 16\n”);input(binary);strcpy(dup,binary);test=check(binary);if(test==0){printf(“\nInvalid Binary Number.”);exit(1);}printf(“\nOriginal Binary No:%s”,dup);compl(binary,a);printf(“\n2’s complement is %s”,a);getch();}void input(char binary[]){printf(“Enter Binary numbers(0 or 1) without spaces up to Max 16 bits:\n”);scanf(“%s”,binary);return;} int check(char binary[]){int i,l,x=1;l=strlen(binary);for(i=0; ichar a[L];/ int l,i; l=strlen(binary); for(i=l-1; i>=0; i–){if(binary[i]==’0′)a[i]=’1′;elsea[i]=’0′;}for(i=l-1; i>=0; i–){if(i==l-1){if(a[i]==’0′)a[i]=’1′;else{a[i]=’0′;check=1;} }OUTPUT:Enter Binary no of Maximum …

Start reading Find Two’s Complement of a Binary Number Using C programming

C Program to Perform Arithmetic Operations Using Switch

ALGORITHM: Begin Enter a, b values. Print ‘MENU’.(i) Print ‘+ Addition’.(ii) Print ‘- Subtraction’.(iii) Print ‘* Multiplication’.(iv) Print ‘/ Division’.(v) Print ‘% Remainder’.(vi) Print ‘E Exit’. Print ‘Enter your choice’. If op==’E’ then goto step 8 otherwise follow the below steps Switch(op)a. case +:i. Print ‘Addition’.ii. c=a+b.iii. Print ‘Sum=’c.iv. breakb. case -:v. Print ‘Subtraction’.vi. c=a-b.vii. …

Start reading C Program to Perform Arithmetic Operations Using Switch

Check a Character is Vowel or not Using C

Check a Character is Vowel or not Using C programming. The following program uses switch case to check all the vowels. #include <stdio.h>int main(){char ch;printf(“\nEnter Single Character: “);scanf(“%c”, &ch);switch (ch){case ‘a’:case ‘A’:printf(“\n\n%c is a vowel”, ch);break;case ‘e’:case ‘E’:printf(“\n\n%c is a vowel”, ch);break;case ‘i’:case ‘I’:printf(“\n\n%c is a vowel”, ch);break;case ‘o’:case ‘O’:printf(“\n\n%c is a vowel”, ch);break;case ‘u’:case …

Start reading Check a Character is Vowel or not Using C

C Program to Compare Two Strings using strcmp()

include include int main(){char s1[20], s2[20];int result;printf(“\nEnter first string: “);gets(s1);printf(“\nEnter second string: “);gets(s2);result = strcmp(s1, s2);if (result == 0)printf(“\nBoth strings are equal”);elseprintf(“\nBoth strings are not equal”);return 0;}OUTPUT:Enter first string: Programming9.com Enter second string: Programming9.com Both strings are equal

Start reading C Program to Compare Two Strings using strcmp()

C Program to Implement Call By Value using Functions

include swap (int, int);main(){int a, b;printf(“\nEnter value of a & b: “);scanf(“%d %d”, &a, &b);printf(“\nBefore Swapping:\n”);printf(“\na = %d\n\nb = %d\n”, a, b);swap(a, b);printf(“\nAfter Swapping:\n”);printf(“\na = %d\n\nb = %d”, a, b);getch();}swap (int a, int b){int temp;temp = a;a = b;b = temp;}OUTPUT:Enter value of a & b: 10 20 Before Swapping: a = 10 b = …

Start reading C Program to Implement Call By Value using Functions

C Program to Find Number of Characters and Words in a String

include include int main(){char str[50];int i=0, word=0, chr=0;printf(“\nEnter Your String: “);gets(str);while (str[i] != ‘\0’){if (str[i] == ‘ ‘){word++;chr++;}elsechr++;i++;}printf(“\nNumber of characters: %d”, chr);printf(“\nNumber of words: %d”, word+1);return 0;}OUTPUT:Enter Your String: Welcome to Programming9 .com Number of characters: 28Number of words: 4

Start reading C Program to Find Number of Characters and Words in a String

C Program to Implement CONTINUE statement

include int main(){int i, n, a, sq;printf(“\n\tProgram finds square of positive numbers only\n”);printf(“\nHow many numbers you want to enter: “);scanf(“%d”, &n);for (i=1; i<=n; i++){printf(“\nEnter Number: “);scanf(“%d”, &a);if (a < 0)continue;sq = a * a;printf(“\nSquare of a Number : %d\n”, sq);}return 0;}OUTPUT:Program finds square of positive numbers only How many numbers you want to enter: 3 …

Start reading C Program to Implement CONTINUE statement