Search
 
SCRIPT & CODE EXAMPLE
 

C

C Arrays and Pointers

#include <stdio.h>
int main() {

  int x[5] = {1, 2, 3, 4, 5};
  int* ptr;

  // ptr is assigned the address of the third element
  ptr = &x[2]; 

  printf("*ptr = %d 
", *ptr);   // 3
  printf("*(ptr+1) = %d 
", *(ptr+1)); // 4
  printf("*(ptr-1) = %d", *(ptr-1));  // 2

  return 0;
}
Comment

C Pointers and Arrays

#include <stdio.h>
int main() {

  int i, x[6], sum = 0;

  printf("Enter 6 numbers: ");

  for(i = 0; i < 6; ++i) {
  // Equivalent to scanf("%d", &x[i]);
      scanf("%d", x+i);

  // Equivalent to sum += x[i]
      sum += *(x+i);
  }

  printf("Sum = %d", sum);

  return 0;
}
Comment

PREVIOUS NEXT
Code Example
C :: bitwise operators 
C :: use frama c online 
C :: c read file from command line 
C :: How to send an array through a pipe 
C :: c code recursive function to print numbers between two numbers 
C :: C/AL Convertion of Decimal to String/Text 
C :: columntransformer in randomizedsearchcv 
C :: Print mark-sheet of students 
C :: c code to mips assembly converter online 
C :: find all hyperlinks <a in p tag 
C :: router solicitation and advertisement magic is used by 
C :: esp local control 
C :: how to find folders from a c program 
C :: print integer to stdout using write or putchar? 
C :: error: invalid type for iteration variable ‘i’ #pragma omp parallel for 
C :: clipboard lib 
C :: unigine 
C :: visa germany algeria 
C :: convert c code to c online 
C :: networkx remove attributes 
C :: unia c 
C :: how to devowel string in c program 
C :: unconstrained box flutter 
C :: inline function in c example 
C :: come fare un programma in c con cui interagire 
C :: function for 2d dynamic array 
C :: C Program to calculate the total execution time of a program 
Dart :: TextStyle underline flutter 
Dart :: How to Create Number Inputfield in Flutter? 
Dart :: showdialog with builder flutter 
ADD CONTENT
Topic
Content
Source link
Name
7+7 =