A

@Adarsh222

String Input index char Output

C
4 years ago
#include <stdio.h> int main() { char string[100],result;//string is always stored in an array int index,stridx; scanf("%s",string); scanf("%d",&stridx); result=string[stridx];

Char occurrence only once && removing duplicate

C
4 years ago
#include <stdio.h> #include <string.h> int main() { int frq[256] = {0}; char a[10] = "adarsh"; for(int i=0;a[i]!='\0';i++){ frq[a[i]]++; }

Basic

C
4 years ago
#include <stdio.h> int main() { int *p,a; a=56; p=&a; printf("%d",*p); return 0; }

calloc

C
4 years ago
#include <stdio.h> #include <stdlib.h> int main() { int n=1,i,j; int *ptr; ptr=(int*)calloc(n,sizeof(int)); for(i=0;i<n;i++){

Malloc

C
4 years ago
//https://csnotes.medium.com/malloc-in-c-for-int-and-char-c3677b857b65 #include <stdio.h> #include <stdlib.h> int main() { int n=1,i,j; int *ptr; ptr=(int*)malloc(n*sizeof(int));

Reverse words in string

C
4 years ago
#include <stdio.h> void rev(char *pstr); void swap(char *bg,char *en); int main(){ char str[]="hii my name is adarsh"; rev(str);

GET_BITS from an integer

C
4 years ago
#include <stdio.h> //Macro to Get bit from the given position #define GET_BITS(data, pos) ((data & ( 1 << pos)) >> pos) int main() { unsigned char value = 16; //value in hex 00010000 unsigned char position = 0; printf("%d\n", GET_BITS(value,position)); //print gets value from the 0th position position = 1;

EVEN OR ODD in bitwise

C
4 years ago
#include <stdio.h> int main() { int num; /* Input number from user */ printf("Enter any number: "); scanf("%d", &num);

Pos or Neg in bitwise

C
4 years ago
#include <stdio.h> int main() { int sign = 0; int data = 0; printf("Enter the number\n"); scanf("%d",&data); //Get the number sign = (data > 0) - (data < 0); // check the sign of the number if(sign == 1) {

Pointer address and value

C
4 years ago
#include<stdio.h> int main(){ int number=50; int *pointer; pointer=&number;/*stores the address of number variable*/ printf("Address of p variable is %x \n",pointer); /*p contains the address of the number*/ /*therefore printing p gives the address of number.*/

For loop using pointers

C
4 years ago
#include <stdio.h> int main() { int n[4] = { 5, 10, 15 ,6}; int i; /*for(i=0;i<4;i++){ printf("%d\n",n[i]); }*/

Using pointers in array to chnge

C
4 years ago
#include <stdio.h> void change(int **p); int main() { int numbers[10] = { 5, 10, 15 }; int *pi; pi = numbers; printf("the no %d \n",*pi); change(&pi); //pass address of pointer

Switch program in c

C
4 years ago
#include <stdio.h> /* Enumeration or Enum in C is a special kind of data type defined by the user. It consists of constant integrals or integers that are given names by a user. The use of enum in C to name the integer values makes the entire program easy to learn, understand, and maintain by the same or even different programmer. Syntax to Define Enum in C An enum is defined by using the ‘enum’ keyword in C, and the use of a comma

Decimal to binary

C
4 years ago
#include <stdio.h> int main() { int a; int b[10]; int i; scanf("%d",&a); for(i=0;a>0;i++){ b[i]=a%2;

C program to store words in an array

C
4 years ago
// C program to store words in an array #include <stdio.h> int main() { int i; // Lets say we have 3 words int n = 4;// 1st word ---

Delete an element of an array

C
4 years ago
// Online C compiler to run C program online #include <stdio.h> int main() { char a[100],s[100]; int i; scanf("%s",s); for(i=0;s[i]!='\0';++i){

Sum of 2 arrays

C
4 years ago
#include <stdio.h> int main () { int a[10],b[10],sum[10],n=3,i,j,k,f; for(i=0;i<n;i++){ scanf("%d",&a[i]); }

Classes and Objects 1

C++
4 years ago
#include <iostream> using namespace std; // create a class class Room { public: double length;//data members double breadth;//access data members:- room1.length = 5.5; double height;

Bubble sort array in assending order

C
4 years ago
#include<stdio.h> void main () { int i, j,temp; int a[10] = { 10, 9, 7, 101, 23, 44, 12, 78, 34, 23}; for(i = 0; i<10; i++) { for(j = i+1; j<10; j++) { if(a[j] > a[i])

Array as pointer

C
4 years ago
#include <stdio.h> #include <stdlib.h> #include <string.h> /*imp one please go through https://www.geeksforgeeks.org/how-to-store-words-in-an-array-in-c/ data_type array_name[rows][columns]; Enter a[0][0]: 56 Enter a[0][1]: 10